Standard events

Table 2-21 describes each standard Open Server event and the argument the corresponding custom event handler should take. It also describes what function the corresponding default event handler performs.

Table 2-21: Description of events

Event

Description

Argument to handler

Default event handler

SRV_ATTENTION

An attention has been received. This event usually occurs when a client calls ct_cancel to stop results processing prematurely. SRV_ATTENTION is an immediate event; Open Server services it as soon as it occurs rather than adding it to the client’s event queue. A SRV_ATTENTION event executes at interrupt level.

SRV_PROC*

The default handler takes no additional action.

SRV_BULK

A client has issued a bulk copy request.

SRV_PROC*

The default handler sends the message “No bulk handler installed” to the client. Open Server discards the bulk data and returns DONE ERROR to the client.

SRV_CONNECT

A Client-Library client has called ct_connect.

SRV_PROC*

The default handler accepts the connection.

SRV_CURSOR

A client has sent a cursor request.

SRV_PROC*

The default handler sends the message “No SRV_CURSOR handler installed” to the client. Open Server returns DONE ERROR to the client.

SRV_DISCONNECT

A request to disconnect a client connection has been made. This event is triggered by a client disconnecting from a server, an Open Server fatal thread error, a SRV_STOP event, or a call to srv_event made from within the application explicitly to disconnect a client. Client-Library programs call ct_close or ct_exit to log out of the Open Server application. Remote Adaptive Server connections terminate when the remote procedure call has completed.

SRV_PROC*

The default handler takes no action.

SRV_DYNAMIC

A client has sent a dynamic SQL request.

SRV_PROC*

The default handler sends the message “No SRV_DYNAMIC handler installed” to the client. Open Server returns DONE ERROR to the client.

SRV_FULLPASSTHRU

A network read for the connection has completed.

(The SRV_T_FULLPASSTHRU property for the thread must have been set to CS_TRUE for this event to occur.

SRV_PROC*

There is no default event handler for this event.

SRV_LANGUAGE

A client has sent a language request, such as a SQL statement. A Client-Library client submits a language request using ct_command and ct_send. isql and other interactive query tools can also send language requests to the Open Server application.

SRV_PROC*

The default handler sends the message “No language handler installed” to the client, along with the first few characters of the language request. Open Server returns DONE ERROR to the client.

SRV_MIGRATE_STATE

This event is triggered whenever the migration state has transitioned to SRV_MIG_READY or SRV_MIG_FAILED, the transition being a result of a migration message from a client.

See “Connection migration” for more details.

SRV_PROC*

The default handler takes no action if the state is SRV_MIG_READY, and thus allows the client to continue with the migration. It logs an error if the state changes to SRV_MIG_FAILED.

SRV_MIGRATE_RESUME

When a client migrates to a new server while waiting for results, the new server invokes the SRV_MIGRATE_RESUME event after the client connection has successfully migrated. If the migration request failed or is cancelled, the event is invoked from the original server.

See “Connection migration” for more details.

SRV_PROC*

The default handler only sends a final done (SRV_DONE_FINAL) to the client to end the results.

SRV_MSG

A client has sent a message.

SRV_PROC*

The default handler sends the message “No SRV_MSG handler installed” to the client. Open Server returns DONE ERROR to the client.

SRV_OPTION

A client has sent an option command.

SRV_PROC*

The default handler sends the message “No SRV_OPTION handler installed” to the client. Open Server returns DONE ERROR to the client.

SRV_RPC

A client or a remote Adaptive Server has issued a remote procedure call (RPC).

SRV_PROC*

The default handler sends the message “RPC < rpcname > received. No remote procedure call handler installed” to the client. Open Server returns a DONE ERROR to the client.

SRV_START

A call to srv_run triggers a SRV_START event. The Open Server application is up and running. The SRV_START event handler is a good place to initialize server resources and to spawn service threads.

SRV_SERVER*

The default handler takes no action.

SRV_STOP

A request to stop the Open Server application has been made, triggered by a call to srv_event or by an Open Server fatal server error. The Open Server application is stopped. srv_run returns CS_SUCCEED if the application requested a SRV_STOP event or CS_FAIL if a fatal server error provoked the SRV_STOP event. A custom handler for this event can perform any necessary cleanup before the Open Server application shuts down.

SRV_SERVER*

The default handler takes no action.

SRV_URGDISCONNECT

This event is only triggered by an Open Server application calling srv_event. In response to this event, Open Server calls a threads SRV_DISCONNECT event handler. Open Server places the event at the top of the threads event queue, so that it is processed as the next event. An application should raise this event if it wants to terminate a thread immediately, bypassing other events in the queue. When a SRV_URGDISCONNECT event is raised, the I/O channel associated with the thread is marked dead.

SRV_PROC*

The default handler takes no action.