anse1 / emacs-libpq

An Emacs 25 module for accessing postgres via libpq.
GNU General Public License v3.0
22 stars 4 forks source link

Queries not interruptible from Emacs with Ctrl-G #17

Closed gnusupport closed 2 years ago

gnusupport commented 3 years ago

I have noticed that queries that take long time are not interruptible by Emacs. Maybe something can be done on that?

I had to stop server to interrupt it.

Maybe there is some function that can be implemented to send some signal to interrupt it?

anse1 commented 3 years ago

GNU Support writes:

I have noticed that queries that take long time are not interruptible by Emacs. Maybe something can be done on that?

I had to stop server to interrupt it.

Maybe there is some function that can be implemented to send some signal to interrupt it?

A PostgreSQL query needs to be cancelled by opening a second connection to the server an cancelling the still-runing one via a cancel key or select pg_cancel_backend(pid). Not sure if this can be done when an emacs module is busy in a function all, need to investigate...

Meanwhile you can work around it by setting a statement timeout. E.g.

(pq:query nnpq-con "set statement_timeout = '1s'") nil (pq:query nnpq-con "select pg_sleep(2)") (pq:error "ERROR: canceling statement due to statement timeout\n" "57014")

gnusupport commented 3 years ago

Well that is good enough! Please close this.