Handling Cancel Requests
You can cancel a query that calls your UDx (usually, by by pressing CTRL+C in vsql). How Vertica handles the cancelation of the query and your UDx depends on whether your UDx is running in fenced or unfenced mode:
- If your UDx is running in unfenced mode, Vertica either stops the function when it requests a new block of input or output, or waits until your function completes running and discards the results.
- If your UDx is running in Fenced Mode, Vertica kills the zygote process that is running your function if it continues processing past a timeout.
See Fenced Mode for more information about running functions in fenced mode.
To give you more control over what happens to your function when the user cancels its query, the Vertica SDK includes an API for some UDxs to handle cancelation. Any function class that inherits from the Vertica::UDXObjectCancelable
class can test whether the query calling it has been canceled using a function named isCanceled()
. Your function can also implement a callback function named cancel()
that Vertica calls when the function's query is canceled. Currently, the two classes that inherit from UDXObjectCancelable
are TransformFunction
and AnalyticFunction
.