Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-23 Thread Michael Paquier
On Sat, May 23, 2015 at 7:43 AM, Tom Lane wrote: > Andres Freund writes: >> This whole discussion seems to be about making it easier to run SELECT >> pg_cancel_backend(pid) FROM pg_stat_activity;. But that shouldn't be >> made easier! If anything harder. > > Indeed. I find it hard to believe tha

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-22 Thread Eric Ridge
On Fri, May 22, 2015 at 4:51 PM Jim Nasby wrote: > Interesting idea. I suspect that would be even more invasive than > modifying the functions though... > Here's the solution. I can't see how anyone could possibly disagree with this... ;) Change the sort order for pg_stat_activity so the curre

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-22 Thread Josh Berkus
On 05/22/2015 03:35 PM, Andres Freund wrote: > On 2015-05-22 17:29:03 -0500, Jim Nasby wrote: >> On 5/22/15 4:51 PM, Tom Lane wrote: >>> Jim Nasby writes: On 5/22/15 3:08 PM, Eric Ridge wrote: > Rather than change the behavior of pg_cancel/terminate_backend(), why not > change pg_sta

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-22 Thread Tom Lane
Andres Freund writes: > This whole discussion seems to be about making it easier to run SELECT > pg_cancel_backend(pid) FROM pg_stat_activity;. But that shouldn't be > made easier! If anything harder. Indeed. I find it hard to believe that there's a real problem here, and I absolutely will resis

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-22 Thread Andres Freund
On 2015-05-22 17:29:03 -0500, Jim Nasby wrote: > On 5/22/15 4:51 PM, Tom Lane wrote: > >Jim Nasby writes: > >>On 5/22/15 3:08 PM, Eric Ridge wrote: > >>>Rather than change the behavior of pg_cancel/terminate_backend(), why not > >>>change pg_stat_activity to exclude the current session? Seems li

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-22 Thread Jim Nasby
On 5/22/15 4:51 PM, Tom Lane wrote: Jim Nasby writes: On 5/22/15 3:08 PM, Eric Ridge wrote: Rather than change the behavior of pg_cancel/terminate_backend(), why not change pg_stat_activity to exclude the current session? Seems like showing a row in pg_stat_activity for "SELECT * FROM pg_st

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-22 Thread Tom Lane
Jim Nasby writes: > On 5/22/15 3:08 PM, Eric Ridge wrote: >> Rather than change the behavior of pg_cancel/terminate_backend(), why not >> change pg_stat_activity to exclude the current session? Seems like showing >> a row in pg_stat_activity for "SELECT * FROM pg_stat_activity" is kinda >> use

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-22 Thread Jim Nasby
On 5/22/15 3:08 PM, Eric Ridge wrote: I find it annoying to have to specifically exclude pg_backend_pid() from pg_stat_activity if I'm trying to kill a bunch of backends at once, and I can't think of any reason why you'd ever want to call a pg_cancel_* function with your own PID. I'm just a l

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-22 Thread Eric Ridge
> On May 19, 2015, at 6:59 PM, Jim Nasby wrote: > > I find it annoying to have to specifically exclude pg_backend_pid() from > pg_stat_activity if I'm trying to kill a bunch of backends at once, and I > can't think of any reason why you'd ever want to call a pg_cancel_* function > with your ow

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-22 Thread Pavel Stehule
2015-05-22 20:28 GMT+02:00 Jim Nasby : > On 5/21/15 7:12 AM, Robert Haas wrote: > >> On Wed, May 20, 2015 at 8:46 PM, Andres Freund >> wrote: >> >>> I've a hard time believing it's actually a good idea to change this. It >>> pretty much seems to only be useful if you're doing unqualified SELECT >

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-22 Thread Fabrízio de Royes Mello
On Fri, May 22, 2015 at 3:28 PM, Jim Nasby wrote: > > You and Andreas think it's fine as-is. > Tom and Jon Nelson maybe don't like it as-is, but won't break backwards compatibility. > David Steele and I seem fine with breaking compat., not sure about Fabrizio. > +1 to add a second parameter and -

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-22 Thread Jim Nasby
On 5/21/15 7:12 AM, Robert Haas wrote: On Wed, May 20, 2015 at 8:46 PM, Andres Freund wrote: I've a hard time believing it's actually a good idea to change this. It pretty much seems to only be useful if you're doing unqualified SELECT pg_cancel_backend(pid) FROM pg_stat_activity; type queries.

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-21 Thread Robert Haas
On Wed, May 20, 2015 at 8:46 PM, Andres Freund wrote: > I've a hard time believing it's actually a good idea to change this. It > pretty much seems to only be useful if you're doing unqualified SELECT > pg_cancel_backend(pid) FROM pg_stat_activity; type queries. I don't see > that as something we

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-20 Thread Alvaro Herrera
Jim Nasby wrote: > BTW, is there a reason we're putting function SQL in that file other than it > was a convenient place? Probably not. I've looked at that file wondering the same thing a number of times ... -- Álvaro Herrerahttp://www.2ndQuadrant.com/ PostgreSQL Development, 2

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-20 Thread Andres Freund
On 2015-05-20 20:38:51 -0400, Tom Lane wrote: > Jim Nasby writes: > > On 5/20/15 6:56 PM, Andres Freund wrote: > >> On 2015-05-20 18:48:59 -0500, Jim Nasby wrote: > >>> and generally if you want to terminate the connection there's easier > >>> ways to do that then "SELECT pg_terminate_backend(pg_b

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-20 Thread Tom Lane
Jim Nasby writes: > On 5/20/15 6:56 PM, Andres Freund wrote: >> On 2015-05-20 18:48:59 -0500, Jim Nasby wrote: >>> and generally if you want to terminate the connection there's easier >>> ways to do that then "SELECT pg_terminate_backend(pg_backend_pid())". >> Which would be what exactly? Say, yo

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-20 Thread Jim Nasby
On 5/20/15 6:56 PM, Andres Freund wrote: On 2015-05-20 18:48:59 -0500, Jim Nasby wrote: and generally if you want to terminate the connection there's easier ways to do that then "SELECT pg_terminate_backend(pg_backend_pid())". Which would be what exactly? Say, you're inside a security definer

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-20 Thread Andres Freund
On 2015-05-20 18:48:59 -0500, Jim Nasby wrote: > and generally if you want to terminate the connection there's easier > ways to do that then "SELECT pg_terminate_backend(pg_backend_pid())". Which would be what exactly? Say, you're inside a security definer function. -- Sent via pgsql-hackers ma

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-20 Thread Jim Nasby
On 5/20/15 11:15 AM, Jon Nelson wrote: On Wed, May 20, 2015 at 9:09 AM, Tom Lane wrote: I think backwards compatibility probably trumps that argument. I have no objection to providing a different call that behaves this way, but changing the behavior of existing applications will face a *much*

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-20 Thread Jim Nasby
On 5/20/15 8:47 AM, Tom Lane wrote: Jim Nasby writes: On 5/19/15 9:19 PM, Fabrízio de Royes Mello wrote: +1 to add a second parameter to current functions. Instead of allow_own_pid, I went with skip_own_pid. I have the function still returning true even when it skips it's own PID... that s

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-20 Thread Jon Nelson
On May 20, 2015 6:43 AM, "David Steele" wrote: > > On 5/20/15 1:40 AM, Jim Nasby wrote: > > On 5/19/15 9:19 PM, Fabrízio de Royes Mello wrote: > >> We could add a second parameter to the current functions: > >> allow_own_pid DEFAULT false. To me that seems better than an > >> entirely

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-20 Thread Jon Nelson
On Wed, May 20, 2015 at 9:09 AM, Tom Lane wrote: > > I think backwards compatibility probably trumps that argument. I have > no objection to providing a different call that behaves this way, but > changing the behavior of existing applications will face a *much* > higher barrier to acceptance. E

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-20 Thread David Steele
On 5/20/15 10:09 AM, Tom Lane wrote: > David Steele writes: >> +1. I agree that cancelling/killing your own process should not be the >> default behavior. > > I think backwards compatibility probably trumps that argument. I have > no objection to providing a different call that behaves this way

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-20 Thread Tom Lane
David Steele writes: > +1. I agree that cancelling/killing your own process should not be the > default behavior. I think backwards compatibility probably trumps that argument. I have no objection to providing a different call that behaves this way, but changing the behavior of existing applica

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-20 Thread Tom Lane
Jim Nasby writes: > On 5/19/15 9:19 PM, Fabrízio de Royes Mello wrote: >> +1 to add a second parameter to current functions. > Instead of allow_own_pid, I went with skip_own_pid. I have the function > still returning true even when it skips it's own PID... that seems a bit > weird, but I think

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-20 Thread David Steele
On 5/20/15 1:40 AM, Jim Nasby wrote: > On 5/19/15 9:19 PM, Fabrízio de Royes Mello wrote: >> We could add a second parameter to the current functions: >> allow_own_pid DEFAULT false. To me that seems better than an >> entirely separate set of functions. >> >> >> +1 to add a second param

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-20 Thread Fabrízio de Royes Mello
On Wed, May 20, 2015 at 2:40 AM, Jim Nasby wrote: > > On 5/19/15 9:19 PM, Fabrízio de Royes Mello wrote: >> >> We could add a second parameter to the current functions: >> allow_own_pid DEFAULT false. To me that seems better than an >> entirely separate set of functions. >> >> >> +1 to

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-19 Thread Jim Nasby
On 5/19/15 9:19 PM, Fabrízio de Royes Mello wrote: We could add a second parameter to the current functions: allow_own_pid DEFAULT false. To me that seems better than an entirely separate set of functions. +1 to add a second parameter to current functions. Instead of allow_own_pid

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-19 Thread Fabrízio de Royes Mello
Em terça-feira, 19 de maio de 2015, Jim Nasby escreveu: > On 5/19/15 6:30 PM, David G. Johnston wrote: > >> On Tue, May 19, 2015 at 4:23 PM, Marko Tiikkaja > >wrote: >> >> On 2015-05-20 00:59, Jim Nasby wrote: >> >> I find it annoying to have to specifically exclu

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-19 Thread Jim Nasby
On 5/19/15 6:30 PM, David G. Johnston wrote: On Tue, May 19, 2015 at 4:23 PM, Marko Tiikkaja mailto:ma...@joh.to>>wrote: On 2015-05-20 00:59, Jim Nasby wrote: I find it annoying to have to specifically exclude pg_backend_pid() from pg_stat_activity if I'm trying to k

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-19 Thread David G. Johnston
On Tue, May 19, 2015 at 4:23 PM, Marko Tiikkaja wrote: > On 2015-05-20 00:59, Jim Nasby wrote: > >> I find it annoying to have to specifically exclude pg_backend_pid() from >> pg_stat_activity if I'm trying to kill a bunch of backends at once, and >> I can't think of any reason why you'd ever wan

Re: [HACKERS] Change pg_cancel_*() to ignore current backend

2015-05-19 Thread Marko Tiikkaja
On 2015-05-20 00:59, Jim Nasby wrote: I find it annoying to have to specifically exclude pg_backend_pid() from pg_stat_activity if I'm trying to kill a bunch of backends at once, and I can't think of any reason why you'd ever want to call a pg_cancel_* function with your own PID. That's a rathe