MySQL Forums
Forum List  »  Router & Proxy

Re: proxy.COM_QUERY Load data infile
Posted by: Diego Medina
Date: September 15, 2007 09:38AM


Thanks for your answer, however, I was able to "intercept it" using the lua-layer.

This is my lua file (just modified from one of the examples
function read_query( packet )
        --This will be TRUE when I send a LOAD DATA INFILE  (not local infile)
        --In my setup, I have a server and then a client, 
        -- The file I am uploading is in the client (in this way I can for sure have the lua-layer see the "data from the file being inserted into MySQL server
        if string.byte(packet) == 34 then
                local query = string.sub(packet, 2)
              --print("This is the data you sent: " .. packet )
                local f_s, f_e, command = string.find(packet, "^%s*(%w+)", 2)
                local option
                print("This is the content of the file from LOAd DATA INFILE: " .. packet)
             -- This part is where I am stuck
             -- How do I format the packet to go to the server
             -- proxy.queries:append(1,string.char(proxy.COM_QUERY) .. models)
             -- return proxy.PROXY_SEND_QUERY
what I do to verify that lua sees the data is:
1- On the MySQL server (same as the mysql-proxy server) I run
shell>/usr/local/mysql-proxy-0.6.0-linux-fc4-x86/sbin/mysql-proxy --proxy-lua-script=/home/lua/test.lua
(Note that I do not add an & at the end so that that shell screen will show me information from the lua-layer)
Than from the client (a different computer than the server, which also has the file I am sending using LOAD DATA INFILE) I login using
shell>/usr/local/mysql/bin/mysql --local-infile --host= --port=4040 --user=root --password test
mysql>load data local infile '/home/wizard/hp.csv' into table test fields terminated by ',' optionally enclosed by '"' lines terminated by "\r\n"(part_number,str)

I need something like
proxy.queries:append(1, string.char(proxy.COM_QUERY) .. "SHOW TABLES FROM " .. option )
but that works with LOAD DATA INFILE

If you need the database sample and the csv file I am using, just let me know.

Thanks you!

Diego Medina
Web Developer

P.S. Please read this post if you are going to post code

Options: ReplyQuote

Written By
September 14, 2007 10:13PM
September 15, 2007 02:58AM
Re: proxy.COM_QUERY Load data infile
September 15, 2007 09:38AM
September 17, 2007 01:05AM
September 16, 2007 10:14PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.