Hello Sebastein,
On 2014-12-03 17:25, Sebastien FLAESCH wrote:
Hi all,
I have a similar question regarding KILL QUERY usage:
We have a C client program using libmysqlclient.so, it is a
single-threaded program.
When running a long query, how can I send the KILL QUERY command when a
SIGINT (CTRL-C)
is caught? (of course we implement a signal handler, so we keep the
control)
=> Is is safe to establish a new connection to the server in the signal
handler, using
mysql_init() + mysql_real_connect(), and execute the KILL QUERY with the
mysql thread
id I got from the initial mysql_init() / mysql_real_connect()?
I made some tests, and it seems to work fine, the long query returns SQL
error -1317:
"Query execution was interrupted" (which is expected)
We want to support SQL interruption properly, so please someone from the
dev team,
give me a clear answer... I don't want to use a side effect or
undocumented feature.
Issuing KILL QUERY from a separate connection is the way to do it. We do
not currently have any CAPI "abort" function - introducing such
functionality would require changes on the protocol level.
Doing all this stuff in a signal handler is certainly risky... no?
Whether it is safe to do I/O extensive work inside a signal handler is
another topic, not related to MySQL client library. Depends on your
particular case and how careful you are about writing handler code which
can be executed at any time. One safe option is that signal handler only
sets a flag informing about the signal and then either the main logic of
your application detects the flag and performs KILL operation, or you
have a separate dedicated thread to do this job.
Rafal (from Connectors/C team @ MySQL)
I could not find the information in the documentation (mysql_real_connect).
I wish there would be an API like mysql_cancel_query(), similar to
Oracle's OCI
OCIBreak().
Thanks!
Seb
On 12/02/2014 05:13 PM, walter harms wrote:
hi list,
when i use CTRL-C to break a query that works fine in interactive mode.
mysql> select sleep(10) ;
^CCtrl-C -- sending "KILL QUERY 24289" to server ...
Ctrl-C -- query aborted.
+-----------+
| sleep(10) |
+-----------+
+-----------+
1 row in set (0.86 sec)
but when i use the noninteractive mode
timeout 5 mysql -BAN -e "select now(); select sleep (100) ; select
now() "
i looks like that but "show full processlist;" shows otherwise and
that is true
as a list of long running querys showed.
Is there a way to make it behave like the interactive version ?
Now it is a bit confusing for everyone.
re,
wh
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql