Oracle 5.0 Reference Manual page 1438

Table of Contents

Advertisement

raw MySQL network protocol packet, you must access the first byte to identify the packet type and
contents. The
whether the authentication was successful:
function read_auth_result(auth)
local state = auth.packet:byte()
if state == proxy.MYSQLD_PACKET_OK then
elseif state == proxy.MYSQLD_PACKET_ERR then
else
end
end
If a long-password capable client tries to authenticate to a server that supports long passwords, but
the user password provided is actually short,
time,
auth.packet:byte()
password protocol. The second time time
will indicate whether the authentication actually succeeded.
15.7.4.7. Manipulating Queries with
The
read_query()
argument, the query packet that was provided. To access the content of the packet, you must parse the
packet contents manually.
For example, you can intercept a query packet and print out the contents using the following function
definition:
function read_query( packet )
if packet:byte() == proxy.COM_QUERY then
end
end
This example checks the first byte of the packet to determine the type. If the type is
Server Command Constants
of the packet type supplied is important. In the case of a
the packet are the text of the query string. In this example, no changes have been made to the query or
the list of queries that will ultimately be sent to the MySQL server.
To modify a query, or add new queries, you must populate the query queue (proxy.queries), then
execute the queries that you have placed into the queue. If you do not modify the original query or the
queue, the query received from the client is sent to the MySQL server verbatim.
When adding queries to the queue, you should follow these guidelines:
• The packets inserted into the queue must be valid query packets. For each packet, you must set the
initial byte to the packet type. If you are appending a query, you can append the query statement to
the rest of the packet.
• Once you add a query to the queue, the queue is used as the source for queries sent to the server.
If you add a query to the queue to add more information, you must also add the original query to the
queue or it will not be executed.
• Once the queue has been populated, you must set the return value from
whether the query queue should be sent to the server.
• When you add queries to the queue, you should add an ID. The ID you specify is returned with the
result set so that you identify each query and corresponding result set. The ID has no other purpose
than as an identifier for correlating the query and result set. When operating in a passive mode,
during profiling for example, you identify the original query and the corresponding result set so that
the results expected by the client can be returned correctly.
MySQL Proxy Scripting
MYSQLD_PACKET_ERR
print("<-- auth ok");
print("<-- auth failed");
print("<-- auth ... don't know: " .. string.format("%q", auth.packet));
will equal 254, indicating that the client should try again using the old
read_query()
function is called once for each query submitted by the client and accepts a single
print("we got a normal query: " .. packet:sub(2))
[1414]), we extract the query from the packet and print it. The structure
and
MYSQLD_PACKET_OK
read_auth_result()
read_auth_result()/
COM_QUERY
1418
constants can be used to identify
will be called twice. The first
is called,
auth.packet:byte()
COM_QUERY
packet, the remaining contents of
read_query()
(see
to indicate

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents