MySQL 5.5 Reference Manual

14.6.4.3. Capturing a Connection with connect_server()

When the proxy accepts a connection from a MySQL client, the
connect_server() function is called.

There are no arguments to the function, but you can use and if
necessary manipulate the information in the
proxy.connection table, which is unique to
each client session.

For example, if you have multiple backend servers, you can
specify which server that connection should use by setting the
value of proxy.connection.backend_ndx to a
valid server number. The following code chooses between two
servers based on whether the current time in minutes is odd or
even: