Commit 21071ece authored by casualet's avatar casualet

add wrapper.lua to the current directory

parent a6c0a985
...@@ -571,7 +571,7 @@ isUnique(const std::string &name, ...@@ -571,7 +571,7 @@ isUnique(const std::string &name,
const auto &found = const auto &found =
std::find(std::get<0>(it).begin(), std::get<0>(it).end(), name); std::find(std::get<0>(it).begin(), std::get<0>(it).end(), name);
if (found != std::get<0>(it).end() if (found != std::get<0>(it).end()
&& (std::get<1>(it) == Key::PRIMARY || std::get<1>(it) == Key::UNIQUE)) { && (std::get<1>(it) == Key::PRIMARY || std::get<1>(it) == Key::UNIQUE ||std::get<1>(it)==Key::FOREIGN_KEY)) {
unique = true; unique = true;
break; break;
} }
......
assert(package.loadlib("/t/cryt/obj/libexecute.so","lua_cryptdb_init"))() local handle = io.popen('pwd')
local result = handle:read("*a")
handle:close()
prefix = result:gsub("\n$", "")
libpath = prefix.."/obj/libexecute.so"
assert(package.loadlib(libpath,
"lua_cryptdb_init"))()
local proto = assert(require("mysql.proto")) local proto = assert(require("mysql.proto"))
local g_want_interim = nil local g_want_interim = nil
...@@ -20,7 +25,7 @@ function read_auth() ...@@ -20,7 +25,7 @@ function read_auth()
proxy.connection.server.dst.port, proxy.connection.server.dst.port,
os.getenv("CRYPTDB_USER") or "root", os.getenv("CRYPTDB_USER") or "root",
os.getenv("CRYPTDB_PASS") or "letmein", os.getenv("CRYPTDB_PASS") or "letmein",
os.getenv("CRYPTDB_SHADOW") or "/t/cryt/shadow") os.getenv("CRYPTDB_SHADOW") or prefix.."/shadow")
-- EDBClient uses its own connection to the SQL server to set up UDFs -- EDBClient uses its own connection to the SQL server to set up UDFs
-- and to manipulate multi-principal state. (And, in the future, to -- and to manipulate multi-principal state. (And, in the future, to
-- store its schema state for single- and multi-principal operation.) -- store its schema state for single- and multi-principal operation.)
...@@ -32,17 +37,16 @@ function disconnect_client() ...@@ -32,17 +37,16 @@ function disconnect_client()
end end
function read_query(packet) function read_query(packet)
printred("read_query========================================================================================")
local status, err = pcall(read_query_real, packet) local status, err = pcall(read_query_real, packet)
if status then if status then
return err return err
else else
print("read_query: " .. err)
return proxy.PROXY_SEND_QUERY return proxy.PROXY_SEND_QUERY
end end
end end
function read_query_result(inj) function read_query_result(inj)
printred("read_query_result========================================================================================")
local status, err = pcall(read_query_result_real, inj) local status, err = pcall(read_query_result_real, inj)
if status then if status then
return err return err
...@@ -53,28 +57,6 @@ function read_query_result(inj) ...@@ -53,28 +57,6 @@ function read_query_result(inj)
end end
function split(pString, pPattern)
local Table = {} -- NOTE: use {n = 0} in Lua-5.0
local fpat = "(.-)" .. pPattern
local last_end = 1
local s, e, cap = pString:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(Table,cap)
end
last_end = e+1
s, e, cap = pString:find(fpat, last_end)
end
if last_end <= #pString then
cap = pString:sub(last_end)
table.insert(Table, cap)
end
return Table
end
-- --
-- Pretty printing -- Pretty printing
-- --
...@@ -100,8 +82,6 @@ function printred(x) ...@@ -100,8 +82,6 @@ function printred(x)
end end
function printline(n) function printline(n)
print("#######n==")
print(n)
-- pretty printing -- pretty printing
if (n) then if (n) then
io.write("+") io.write("+")
...@@ -139,14 +119,8 @@ function prettyNewQuery(q) ...@@ -139,14 +119,8 @@ function prettyNewQuery(q)
return return
end end
end end
list = split(q,',') print(greentext("NEW QUERY: ")..makePrintable(q))
for i=1,#list do
io.write(string.sub(list[i],1,40))
print("")
end
--print(greentext("NEW QUERY: ")..makePrintable(q))
end end
-- --
...@@ -161,7 +135,8 @@ end ...@@ -161,7 +135,8 @@ end
function read_query_real(packet) function read_query_real(packet)
local query = string.sub(packet, 2) local query = string.sub(packet, 2)
--printred("QUERY: ".. query) print("================================================")
printred("QUERY: ".. query)
if string.byte(packet) == proxy.COM_INIT_DB then if string.byte(packet) == proxy.COM_INIT_DB then
query = "USE `" .. query .. "`" query = "USE `" .. query .. "`"
...@@ -186,12 +161,6 @@ function read_query_real(packet) ...@@ -186,12 +161,6 @@ function read_query_real(packet)
end end
end end
function printRowsAndFields(inj)
local resultset = inj.resultset
end
function read_query_result_real(inj) function read_query_result_real(inj)
local query = inj.query:sub(2) local query = inj.query:sub(2)
prettyNewQuery(query) prettyNewQuery(query)
...@@ -228,9 +197,12 @@ function read_query_result_real(inj) ...@@ -228,9 +197,12 @@ function read_query_result_real(inj)
interim_fields[i] = interim_fields[i] =
{ type = resfields[i].type, { type = resfields[i].type,
name = resfields[i].name } name = resfields[i].name }
io.write(string.format("%-10s|",rfi.name)) io.write(string.format("%-20s|",rfi.name))
end end
print()
printline(#resfields)
local resrows = resultset.rows local resrows = resultset.rows
if resrows then if resrows then
for row in resrows do for row in resrows do
...@@ -242,10 +214,9 @@ function read_query_result_real(inj) ...@@ -242,10 +214,9 @@ function read_query_result_real(inj)
print() print()
end end
end end
--printline(#resfields)
end
print(greentext("ENCRYPTED RESULTS END")) printline(#resfields)
end
return next_handler("results", true, client, interim_fields, interim_rows, return next_handler("results", true, client, interim_fields, interim_rows,
resultset.affected_rows, resultset.insert_id) resultset.affected_rows, resultset.insert_id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment