tds-fdw / tds_fdw

A PostgreSQL foreign data wrapper to connect to TDS databases (Sybase and Microsoft SQL Server)
Other
381 stars 102 forks source link

Ctrl+C doesn't cancel a query in psql #26

Closed GeoffMontee closed 1 year ago

GeoffMontee commented 9 years ago

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 commented 9 years ago

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 commented 8 years ago

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

beaud76 commented 2 years ago

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

GeoffMontee commented 1 year ago

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