Re: Considering signal handling in plpython again

2018-06-21 Thread Hubert Zhang
Hi Heikki, Not working on it now, you can go ahead. On Fri, Jun 22, 2018 at 12:56 AM, Heikki Linnakangas wrote: > Hi Hubert, > > Are you working on this, or should I pick this up? Would be nice to get > this done as soon as v12 development begins. > > - Heikki > -- Thanks Hubert Zhang

Re: Considering signal handling in plpython again

2018-06-21 Thread Heikki Linnakangas
Hi Hubert, Are you working on this, or should I pick this up? Would be nice to get this done as soon as v12 development begins. - Heikki

Re: Considering signal handling in plpython again

2018-05-16 Thread Heikki Linnakangas
On 16 May 2018 16:50:24 EEST, Hubert Zhang wrote: >There are remaining two problems > >1. Do we need to consider when to delete the extension hook or it's not >necessary? No, PostgreSQL never unloads shared libraries, so that can be ignored. We used to, and that's what _PG_fini() was for. But

Re: Considering signal handling in plpython again

2018-05-16 Thread Hubert Zhang
There are remaining two problems 1. Do we need to consider when to delete the extension hook or it's not necessary? As the destroy function _PG_fini doesn't work, I cannot find a good place to reset to hook gracefully. I tested the drop language plpythonu statement which will not remove th

Re: Considering signal handling in plpython again

2018-05-14 Thread Heikki Linnakangas
On 14/05/18 10:56, Hubert Zhang wrote: For nested SPI case, one option is to turn off the bool variable when entering the SPI function(PLy_spi_prepare, PLy_spi_execute, PLy_cursor etc.) and turn on the bool variable again when exiting the SPI function. Yeah, that seems reasonable. - Heikki

Re: Considering signal handling in plpython again

2018-05-14 Thread Hubert Zhang
For nested SPI case, one option is to turn off the bool variable when entering the SPI function(PLy_spi_prepare, PLy_spi_execute, PLy_cursor etc.) and turn on the bool variable again when exiting the SPI function. If it's OK, we could follow this way to update Heikki's patch. --Hubert On Fri, May

Re: Considering signal handling in plpython again

2018-05-11 Thread Heikki Linnakangas
On 11 May 2018 10:01:56 EEST, Hubert Zhang wrote: >2. Add a flag in hook function to indicate whether to call >Py_AddPendingCall. >This is straightforward.(I prefer it) Yeah, that's what I had in mind, too. A global bool variable that's set when you enter libpython, and cleared on return. Need

Re: Considering signal handling in plpython again

2018-05-11 Thread Hubert Zhang
Thanks Heikki and Robert for your comments. I reviewed Heikki's patch and let's enhance it. As Heikki mentioned, there is a problem when no Python code is being executed. I tested it in the following case "select pysleep();" and then type ctrl-c, query cancelled successfully.(Patch works:)) "se

Re: Considering signal handling in plpython again

2018-05-10 Thread Robert Haas
On Thu, May 10, 2018 at 10:50 AM, Heikki Linnakangas wrote: > I came up with the attached patch, which is similar to Mario's, but it > introduces a new "hook" for this. I'd rather have the hook be executed whenever ProcessInterrupts() is called, rather than only in the query-cancel case. -- Rob

Re: Considering signal handling in plpython again

2018-05-10 Thread Heikki Linnakangas
On 10/05/18 09:32, Hubert Zhang wrote: Hi all, I want to support canceling for a plpython query which may be a busy loop. I found some discussions on pgsql-hackers 2 years ago. Below is the link. https://www.postgresql.org/message-id/cafywgj3+xg7ecl2nu-mxx6p+o6c895pm3myz-b+9n9dffeh...@mail.gma

Considering signal handling in plpython again

2018-05-09 Thread Hubert Zhang
Hi all, I want to support canceling for a plpython query which may be a busy loop. I found some discussions on pgsql-hackers 2 years ago. Below is the link. https://www.postgresql.org/message-id/cafywgj3+xg7ecl2nu-mxx6p+o6c895pm3myz-b+9n9dffeh...@mail.gmail.com Mario wrote a patch to fix this p