STOP_STATEMENT

STOP_STATEMENT stops or aborts an active statement.

To find a statement by ID, see SHOW_SERVER_STATUS and SHOW_CONNECTIONS.

Tip

Some DBMSs call this process killing a session, terminating a job, or kill query

Permissions

The role must have the SUPERUSER permissions.

Syntax

stop_statement_statement ::=
    SELECT STOP_STATEMENT(stmt_id)
    ;

stmt_id ::= bigint

Parameters

Parameter

Description

stmt_id

The statement ID to stop

Returns

This utility does not return any value, and always succeeds even if the statement does not exist, or has already stopped.

Notes

  • This utility always succeeds even if the statement does not exist, or has already stopped.

Examples

Using SHOW_CONNECTIONS to get statement IDs

Tip

Use SHOW_SERVER_STATUS to find statments from across the entire cluster, or SHOW_CONNECTIONS to show statements from the current worker the client is connected to.

t=> SELECT SHOW_CONNECTIONS();
ip           | conn_id | conn_start_time     | stmt_id | stmt_start_time     | stmt
-------------+---------+---------------------+---------+---------------------+--------------------------
192.168.1.91 |     103 | 2019-12-24 00:01:27 |     129 | 2019-12-24 00:38:18 | SELECT GET_DATE(), * F...
192.168.1.91 |      23 | 2019-12-24 00:01:27 |      -1 | 2019-12-24 00:01:27 |
192.168.1.91 |      22 | 2019-12-24 00:01:27 |      -1 | 2019-12-24 00:01:27 |
192.168.1.91 |      26 | 2019-12-24 00:01:28 |      -1 | 2019-12-24 00:01:28 |

The statement ID we’re interested in is 129. We can now stop this statement:

t=> SELECT STOP_STATEMENT(129)
executed