There are special queries, such as SET and PREPARE, that modify the state of the connection and may break request switching, and therefore, these need to be handled differently.
On receiving a request with special queries, NetScaler sends an OK response to the client and additionally, stores the request in the connection.
When a non-special query, such as INSERT and SELECT, is received along with a stored query, the NetScaler first, looks for the server-side connection on which the stored query has already been sent to the database server. If no such connections exist, NetScaler creates a new connection, and sends the stored query first, and then, sends the request with the non-special query.
In case of SET, USE db, and INIT_DB special queries, the appliance modifies a field in the server side connection corresponding to the special query. This results in better reuse of the server side connection.
Only 16 queries are stored in each connection.
The following is a list of the special queries for which NetScaler has a modified behavior.
- SET query
- The SET SQL queries define variables that are associated with the connection. These queries are also used to define global variables, but as of now, NetScaler is unable to differentiate between local and global variables. For this query, the NetScaler uses the 'store and forward' mechanism.
- USE <db> query
- Using this query, the user can change the database associated with a connection. In this case, NetScaler parses the <db> value sent and modifies a field in the server side connection to reflect the new database to be used.
- INIT_DB command
- Using this query, the user can change the database associated with a connection. In this case, NetScaler parses the <init_db> value sent and modifies a field in the server side connection to reflect the new database to be used.
- NetScaler stops request switching on receiving this command.
- PREPARE query
- This query is used to create prepared statements that are associated with a connection. For this query, the NetScaler uses the 'store and forward' mechanism.