Stored system procedures for PostgreSQL

A stored system procedure contains SQL code that you can reuse. Spanner provides stored system procedures for you to use. You can't create your own stored procedure in Spanner. You can only execute one stored procedure at a time in a CALL statement.

Stored system procedures

To execute a stored system procedure, you use the CALL statement:

CALL procedure_name(parameters);

Replace procedure_name with the name of the stored system procedure.

Spanner supports the following stored system procedures:

Query cancellation

This section describes the query cancellation stored system procedure.

Syntax

Cancels a query with the specified query_id.

CALL spanner.cancel_query(query_id)

Description

This stored system procedure has the following parameters:

Parameter Type Description
query_id STRING Specifies the ID for the query that you want to cancel.

Query cancellations might fail in the following circumstances:

  • When Spanner servers are busy due to heavy query loads.
  • When the query is in the process of restarting due to an error.

In both cases, you can run the query cancellation stored system procedure again.