I'm running a query within a thread and set a timeout for it to execute, or another way of stopping it would be for the user to cancel the select
. The problem is that I stop the thread but the query continues to run in the database.
I had the idea to stop the query with a command of postgresql
so I need the pid
of the query, and then do the following select:
(
SELECT
p.pid
FROM
pg_stat_activity p
WHERE
state = 'active'
AND query LIKE '%SELECT * FROM GCEPDC02, pg_sleep(%'
AND query NOT LIKE '%FROM pg_stat_activity%')
But this select
does not return anything, any suggestions?