MySQL Proxy Scripting
1410
SELECT * FROM City;
EXPLAIN SELECT * FROM City;
In both of these examples, the client would have received more result sets than expected. Regardless
of how you manipulate the incoming query and the returned result, the number of queries returned by
the proxy must match the number of original queries sent by the client.
You could adjust the client to handle the multiple result sets sent by the proxy, but in most cases you
will want the existence of the proxy to remain transparent. To ensure that the number of queries and
result sets match, you can use the MySQL Proxy
read_query_result()
to extract the additional
result set information and return only the result set the client originally requested back to the client.
You can achieve this by giving each query that you add to the query queue a unique ID, then filter out
queries that do not match the original query ID when processing them with
read_query_result()
.
15.7.4.2. Internal Structures
There are a number of internal structures within the scripting element of MySQL Proxy. The primary
structure is
proxy
and this provides an interface to the many common structures used throughout the
script, such as connection lists and configured backend servers. Other structures, such as the incoming
packet from the client and result sets are only available within the context of one of the scriptable
functions.
The following table describes common attributes of the MySQL
proxy
scripting element.
Attribute
Description
connection
A structure containing the active client connections. For a list of
attributes, see
proxy.connection
[1410]
.
servers
A structure containing the list of configured backend servers. For a list
of attributes, see
proxy.global.backends
[1411]
.
queries
A structure containing the queue of queries that will be sent to
the server during a single client query. For a list of attributes, see
proxy.queries
[1411]
.
PROXY_VERSION
The version number of MySQL Proxy, encoded in hex. You can use
this to check that the version number supports a particular option from
within the Lua script. Note that the value is encoded as a hex value, so
to check the version is at least 0.5.1 you compare against
0x00501
.
proxy.connection
The
proxy.connection
object is read only, and provides information about the current connection,
and is split into a
client
and
server
tables. This enables you to examine information about both the
incoming client connections to the proxy (
client
), and to the backend servers (
server
).
The following table describes the client and server attributes of the
proxy.connection
object.
Attribute
Description
client.default_db
Default database requested by the client
client.username
User name used to authenticate
client.scrambled_password
The scrambled version of the password used to authenticate
client.dst.name
The combined
address:port
of the Proxy port used by this
client (should match the
--proxy-address
[1403]
configuration
parameter)
client.dst.address
The IP address of the of the Proxy port used by this client
client.dst.port
The port number of the of the Proxy port used by this client
client.src.name
The combined
address:port
of the client (originating) TCP/IP
endpoint
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...