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 t...@sss.pgh.pa.us wrote: Andres Freund and...@anarazel.de 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

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

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

2015-05-22 Thread Tom Lane
Jim Nasby jim.na...@bluetreble.com 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

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 jim.na...@bluetreble.com 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_*

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 jim.na...@bluetreble.com writes: On 5/22/15 3:08 PM, Eric Ridge wrote: Rather than change the behavior of pg_cancel/terminate_backend(), why not change

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 jim.na...@bluetreble.com 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

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

2015-05-22 Thread Tom Lane
Andres Freund and...@anarazel.de 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

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 jim.na...@bluetreble.com 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

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 jim.na...@bluetreble.com 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

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 jim.na...@bluetreble.com: On 5/21/15 7:12 AM, Robert Haas wrote: On Wed, May 20, 2015 at 8:46 PM, Andres Freund and...@anarazel.de 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

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 jim.na...@bluetreble.com 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

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 and...@anarazel.de 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

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 and...@anarazel.de 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

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 jim.na...@bluetreble.com 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.

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 parameter to

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

2015-05-20 Thread Tom Lane
David Steele da...@pgmasters.net 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

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

2015-05-20 Thread Tom Lane
Jim Nasby jim.na...@bluetreble.com 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

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

2015-05-20 Thread Jon Nelson
On May 20, 2015 6:43 AM, David Steele da...@pgmasters.net 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

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 da...@pgmasters.net 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

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 t...@sss.pgh.pa.us 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

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 jim.na...@bluetreble.com 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

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

2015-05-20 Thread Tom Lane
Jim Nasby jim.na...@bluetreble.com 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

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

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 20:38:51 -0400, Tom Lane wrote: Jim Nasby jim.na...@bluetreble.com 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

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 t...@sss.pgh.pa.us 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

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,

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

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

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 ma...@joh.to mailto:ma...@joh.towrote: 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

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 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 kill a bunch of backends at once, and I can't think of any reason why you'd

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 jim.na...@bluetreble.com escreveu: On 5/19/15 6:30 PM, David G. Johnston wrote: On Tue, May 19, 2015 at 4:23 PM, Marko Tiikkaja ma...@joh.to mailto:ma...@joh.towrote: On 2015-05-20 00:59, Jim Nasby wrote: I find it annoying to have

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

2015-05-19 Thread Jim Nasby
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. Any objections to modifying those functions so