tds_fdw icon indicating copy to clipboard operation
tds_fdw copied to clipboard

Ctrl+C doesn't cancel a query in psql

Open GeoffMontee opened this issue 9 years ago • 3 comments

Ctrl+C doesn't cancel a query running against tds_fdw in psql. I'm guessing any program linked with libpq will not be able to cancel a query running against tds_fdw.

I wonder if pg_cancel_backend() and pg_terminate_backend() also have issues cancelling a running query?

I might need to write an interrupt handler for tds_fdw using dbsetinterrupt().

GeoffMontee avatar Jun 07 '15 00:06 GeoffMontee

It looks like this affects both pg_cancel_backend() and pg_terminate_backend().

postgres=# SELECT pid, state, query FROM pg_stat_activity;
  pid  | state  |                      query                      
-------+--------+-------------------------------------------------
  7245 | active | SELECT * FROM mssql_table;
 11207 | active | SELECT pid, state, query FROM pg_stat_activity;
(2 rows)

postgres=# SELECT pg_cancel_backend(7245);                
 pg_cancel_backend 
-------------------
 t
(1 row)

postgres=# SELECT pid, state, query FROM pg_stat_activity;
  pid  | state  |                      query                      
-------+--------+-------------------------------------------------
  7245 | active | SELECT * FROM mssql_table;
 11207 | active | SELECT pid, state, query FROM pg_stat_activity;
(2 rows)

postgres=# SELECT pg_terminate_backend(7245);
 pg_terminate_backend 
----------------------
 t
(1 row)

postgres=# SELECT pid, state, query FROM pg_stat_activity;
  pid  | state  |                      query                      
-------+--------+-------------------------------------------------
  7245 | active | SELECT * FROM mssql_table;
 11207 | active | SELECT pid, state, query FROM pg_stat_activity;
(2 rows)

GeoffMontee avatar Jun 12 '15 20:06 GeoffMontee

It looks like a similar problem was recently fixed in postgres_fdw: https://github.com/postgres/postgres/commit/f039eaac7131ef2a4cf63a10cf98486f8bcd09d2

GeoffMontee avatar May 07 '16 18:05 GeoffMontee

"I might need to write an interrupt handler for tds_fdw using dbsetinterrupt()." => that would be great :-)

beaud76 avatar Mar 28 '22 09:03 beaud76

I believe @deathwish implemented this functionality in PR #336.

GeoffMontee avatar Jul 15 '23 00:07 GeoffMontee