### Description
I noticed that sql_query does not work (using latest 5.8 on Debian 12) when called from `tcp:closed` event_route: ``` event_route [tcp:closed] { # Handle TCP connection close # Delete possible leftover registration if ($conid) sql_query("sip_proxy_cache", "DELETE FROM location WHERE server_id=0 AND connection_id=$conid", "result"); } ``` The query produces errors: ``` 2024-05-07T11:30:14.785915+03:00 siika /usr/bin/sip-proxy[2848078]: CRITICAL: sqlops [sqlops.c:213]: sql_check_connection(): no database handle with reconnect disabled 2024-05-07T11:30:14.785978+03:00 siika /usr/bin/sip-proxy[2848078]: ERROR: sqlops [sqlops.c:232]: sql_query(): invalid connection to database 2024-05-07T11:30:14.786013+03:00 siika /usr/bin/sip-proxy[2848078]: ERROR: sqlops [sqlops.c:237]: sql_query(): with query [DELETE FROM location WHERE server_id=0 AND connection_id=7] ``` I added the last debug message in order to find out where the error comes from.
The same query works fine when executed from regular route and earlier (but don't remember when), the same query worked fine also from `tcp:closed` event_route.
This may be related to https://github.com/kamailio/kamailio/issues/3768.