Thread: Perl DBI::Pg - Stop button
Hello again, I have searched around for an answer to this for a while but not found a completely convincing one... Whats the best way to terminate a query when the user presses the stop button? I know that apache only discovers that the client has gone when it tries to send data back - will this require some child process to send data to the client while a query is being performed? I am hoping theres an existing tried and tested solution?! Thanks, Matt
Mr Mat psql-mail <psql-mail@freeuk.com> writes: > Whats the best way to terminate a query when the user presses the stop > button? Send a cancel request. I don't know whether the DBI/DBD stack supports that though :-( regards, tom lane
On Wednesday 07 May 2003 3:55 am, Tom Lane wrote: > Mr Mat psql-mail <psql-mail@freeuk.com> writes: > > Whats the best way to terminate a query when the user presses the stop > > button? > > Send a cancel request. > > I don't know whether the DBI/DBD stack supports that though :-( I think the thrust of Matt's question was whether there is any way to know when the user presses "stop" in their browser from the server end. Unfortunately, since HTTP is a stateless protocol, the short answer is no. This is of course simple if you have a java applet sitting on your page connecting to your server - it can signal out of band. [Not often I follow-up a post by Tom ;-] -- Richard Huxton
What does 'out of band' mean, ( except a entertainment booking agent's worst nightmare ;-)? Richard Huxton wrote: > On Wednesday 07 May 2003 3:55 am, Tom Lane wrote: > >>Mr Mat psql-mail <psql-mail@freeuk.com> writes: >> >>>Whats the best way to terminate a query when the user presses the stop >>>button? >> >>Send a cancel request. >> >>I don't know whether the DBI/DBD stack supports that though :-( > > > I think the thrust of Matt's question was whether there is any way to know > when the user presses "stop" in their browser from the server end. > Unfortunately, since HTTP is a stateless protocol, the short answer is no. > > This is of course simple if you have a java applet sitting on your page > connecting to your server - it can signal out of band. > > [Not often I follow-up a post by Tom ;-]
Dennis Gearon <gearond@cvc.net> writes: > What does 'out of band' mean, ( except a entertainment booking agent's worst nightmare ;-)? It means the cancel request flows across a separate connection. regards, tom lane
I don't see why HTTP being a stateless protocol should mean that an app can't tell if a user disconnects from the webserver. The webserver in most cases knows reasonably promptly, and the other cases after a timeout. If that were not possible, webservers would be wasting a lot of resources by keeping them around long after disconnects. From my dim memory, if you are using CGI and Apache, when the stop button is hit and when you try to print something, you get a SIGTERM and possibly a SIGPIPE (but your app could be dead by then :) ). Plus the print returns false if you are still around. If you are using Modperl and Apache >=1.3.6, when the stop button is hit, and you try to print something, you get a SIGPIPE, and the print returns a false. I don't think you get a SIGTERM. AFAIK the print doesn't return a false immediately even if you turn off buffering, so expect a delay in detection - depends on how much and how often you print (not sure if you can change this, e.g. tcp options etc). If you are using FCGI (at least the versions I tested), when the stop button is hit, and you try to print something, you don't get a SIGPIPE, nor does the print fail. So if you want to detect disconnections, you would want to serve such requests with either CGI or modperl. For mod_perl see: http://perl.apache.org/docs/1.0/guide/debug.html#Handling_the__User_pressed_Stop_button__case Your mileage may vary. Test first. So far if I don't want to print anything but need to check if still connected, print "\0" does what I want. As for sending a cancel. I'm not sure how to do it with DBI::Pg. Would be good to know. Have a nice day, Link. At 07:32 AM 5/7/2003 +0100, Richard Huxton wrote: >I think the thrust of Matt's question was whether there is any way to know >when the user presses "stop" in their browser from the server end. >Unfortunately, since HTTP is a stateless protocol, the short answer is no. > >This is of course simple if you have a java applet sitting on your page >connecting to your server - it can signal out of band. > >[Not often I follow-up a post by Tom ;-] >-- > Richard Huxton > > >---------------------------(end of broadcast)--------------------------- >TIP 3: if posting/reading through Usenet, please send an appropriate >subscribe-nomail command to majordomo@postgresql.org so that your >message can get through to the mailing list cleanly