Commit ee950f9a authored by casualet's avatar casualet

able to show create table, return empty set because the results will be diffcult to recovery

parent 0fed4f0f
OBJDIR := obj
TOP := $(shell echo $${PWD-`pwd`})
CXX := g++
AR := ar
## -g -O0 -> -O2
CXXFLAGS := -g -O0 -fno-strict-aliasing -fno-rtti -fwrapv -fPIC \
-Wall -Werror -Wpointer-arith -Wendif-labels -Wformat=2 \
-Wextra -Wmissing-noreturn -Wwrite-strings -Wno-unused-parameter \
-Wno-deprecated \
-Wmissing-declarations -Woverloaded-virtual \
-Wunreachable-code -D_GNU_SOURCE -std=c++0x -I$(TOP)
LDFLAGS := -L$(TOP)/$(OBJDIR) -Wl,--no-undefined
## Copy conf/config.mk.sample to conf/config.mk and adjust accordingly.
include conf/config.mk
## Use RPATH only for debug builds; set RPATH=1 in config.mk.
ifeq ($(RPATH),1)
LDRPATH := -Wl,-rpath=$(TOP)/$(OBJDIR) -Wl,-rpath=$(TOP)
endif
CXXFLAGS += -I$(MYBUILD)/include \
-I$(MYSRC)/include \
-I$(MYSRC)/sql \
-I$(MYSRC)/regex \
-I$(MYBUILD)/sql \
-DHAVE_CONFIG_H -DMYSQL_SERVER -DEMBEDDED_LIBRARY -DDBUG_OFF \
-DMYSQL_BUILD_DIR=\"$(MYBUILD)\"
LDFLAGS += -lpthread -lrt -ldl -lcrypt -lreadline
## To be populated by Makefrag files
OBJDIRS :=
.PHONY: all
all:
.PHONY: install
install:
.PHONY: clean
clean:
rm -rf $(OBJDIR)
.PHONY: doc
doc:
doxygen CryptDBdoxgen
.PHONY: whitespace
whitespace:
find . -name '*.cc' -o -name '*.hh' -type f -exec sed -i 's/ *$//' '{}' ';'
.PHONY: always
always:
# Eliminate default suffix rules
.SUFFIXES:
# Delete target files if there is an error (or make is interrupted)
.DELETE_ON_ERROR:
# make it so that no intermediate .o files are ever deleted
.PRECIOUS: %.o
$(OBJDIR)/%.o: %.cc
@mkdir -p $(@D)
$(CXX) -MMD $(CXXFLAGS) -c $< -o $@
echo $@ $<
@echo "11111111111111111111111"
$(OBJDIR)/%.o: $(OBJDIR)/%.cc
@mkdir -p $(@D)
$(CXX) -MMD $(CXXFLAGS) -c $< -o $@
@echo "2222222222222222222222"
include crypto/Makefrag
include parser/Makefrag
include main/Makefrag
#include test/Makefrag
include util/Makefrag
include udf/Makefrag
include mysqlproxy/Makefrag
#include tools/import/Makefrag
#include tools/learn/Makefrag
#include scripts/Makefrag
##OBJDIRS = crypto parser main util udf mysqlproxy
$(OBJDIR)/.deps: $(foreach dir, $(OBJDIRS), $(wildcard $(OBJDIR)/$(dir)/*.d))
@mkdir -p $(@D)
perl mergedep.pl $@ $^
echo "after merge"
echo $^
-include $(OBJDIR)/.deps
# CryptdbModify # Newcryptdb
Cryptdb originated from MIT. This is a modified version try to add new features and fix bugs we meet in our environment. Cryptdb originated from MIT. This is a modified version try to add new features and fix bugs we meet in our environment.
Introduction to the features included will be posted at yiwenshao.github.io. Introduction to the features included will be posted at yiwenshao.github.io.
...@@ -22,3 +22,11 @@ make ...@@ -22,3 +22,11 @@ make
If you meet any problems installing it, contact me via shaoyiwenetATgmailDotcom. If you meet any problems installing it, contact me via shaoyiwenetATgmailDotcom.
new features added
+ set user variable
+ timestamp
+ show create table
find . | grep '\.cc$\|\.c$\|\.h$\|\.hh$' | xargs ctags
rm cscope*
find . | grep '\.cc$\|\.c$\|\.h$\|\.hh$' > cscope.files
cscope -R -b -i cscope.files
This diff is collapsed.
This diff is collapsed.
sudo gdb `which mysql-proxy` `ps aux | grep 'mysql-proxy.cnf' |grep -v grep | awk '{print $2}'`
...@@ -861,7 +861,6 @@ Analysis::getDatabaseMeta(const std::string &db) const ...@@ -861,7 +861,6 @@ Analysis::getDatabaseMeta(const std::string &db) const
bool Analysis::tableMetaExists(const std::string &db, bool Analysis::tableMetaExists(const std::string &db,
const std::string &table) const const std::string &table) const
{ {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
return this->nonAliasTableMetaExists(db, unAliasTable(db, table)); return this->nonAliasTableMetaExists(db, unAliasTable(db, table));
} }
...@@ -885,7 +884,6 @@ std::string Analysis::getAnonTableName(const std::string &db, ...@@ -885,7 +884,6 @@ std::string Analysis::getAnonTableName(const std::string &db,
const std::string &table, const std::string &table,
bool *const is_alias) const bool *const is_alias) const
{ {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
// tell the caller if you are giving him an alias // tell the caller if you are giving him an alias
if (is_alias) { if (is_alias) {
*is_alias = this->isAlias(db, table); *is_alias = this->isAlias(db, table);
......
...@@ -60,7 +60,7 @@ class CreateTableHandler : public DDLHandler { ...@@ -60,7 +60,7 @@ class CreateTableHandler : public DDLHandler {
TABLE_LIST *const tbl = TABLE_LIST *const tbl =
rewrite_table_list(new_lex->select_lex.table_list.first, rewrite_table_list(new_lex->select_lex.table_list.first,
tm->getAnonTableName()); tm->getAnonTableName());
//new table_list only contain one element
new_lex->select_lex.table_list = new_lex->select_lex.table_list =
*oneElemListWithTHD<TABLE_LIST>(tbl); *oneElemListWithTHD<TABLE_LIST>(tbl);
......
...@@ -1289,11 +1289,40 @@ class ShowTablesHandlers : public DMLHandler { ...@@ -1289,11 +1289,40 @@ class ShowTablesHandlers : public DMLHandler {
virtual AbstractQueryExecutor *rewrite(Analysis &a, LEX *lex) const virtual AbstractQueryExecutor *rewrite(Analysis &a, LEX *lex) const
{ {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
return new ShowTablesExecutor(); return new ShowTablesExecutor();
} }
}; };
//add show create table handler
class ShowCreateTableHandler: public DMLHandler{
virtual void gather(Analysis &a, LEX *const lex) const
{
}
virtual AbstractQueryExecutor *rewrite(Analysis &a, LEX *lex) const
{
int elements = lex->select_lex.table_list.elements;
assert(elements==1);
TABLE_LIST *tbl = lex->select_lex.table_list.first;
std::string db(tbl->db);
std::string tbn(tbl->table_name);
TableMeta &tbm = a.getTableMeta(db,tbn);
//rewrite the table list here
LEX *const new_lex = copyWithTHD(lex);
tbl = rewrite_table_list(new_lex->select_lex.table_list.first,tbm.getAnonTableName());
new_lex->select_lex.table_list = *oneElemListWithTHD<TABLE_LIST>(tbl);
return new ShowCreateTableExecutor(*new_lex);
}
};
// FIXME: Add test to make sure handlers added successfully. // FIXME: Add test to make sure handlers added successfully.
SQLDispatcher *buildDMLDispatcher() SQLDispatcher *buildDMLDispatcher()
{ {
...@@ -1324,6 +1353,11 @@ SQLDispatcher *buildDMLDispatcher() ...@@ -1324,6 +1353,11 @@ SQLDispatcher *buildDMLDispatcher()
h = new ShowTablesHandlers; h = new ShowTablesHandlers;
dispatcher->addHandler(SQLCOM_SHOW_TABLES, h); dispatcher->addHandler(SQLCOM_SHOW_TABLES, h);
//added
h = new ShowCreateTableHandler;
dispatcher->addHandler(SQLCOM_SHOW_CREATE,h);
return dispatcher; return dispatcher;
} }
...@@ -1332,13 +1366,9 @@ DMLQueryExecutor:: ...@@ -1332,13 +1366,9 @@ DMLQueryExecutor::
nextImpl(const ResType &res, const NextParams &nparams) nextImpl(const ResType &res, const NextParams &nparams)
{ {
reenter(this->corot) { reenter(this->corot) {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
std::cout<<RED_BEGIN<<"rewritten DML: "<<this->query<<COLOR_END<<std::endl; std::cout<<RED_BEGIN<<"rewritten DML: "<<this->query<<COLOR_END<<std::endl;
yield return CR_QUERY_AGAIN(this->query); yield return CR_QUERY_AGAIN(this->query);
TEST_ErrPkt(res.success(), "DML query failed against remote database"); TEST_ErrPkt(res.success(), "DML query failed against remote database");
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
yield { yield {
try { try {
return CR_RESULTS(Rewriter::decryptResults(res, this->rmeta)); return CR_RESULTS(Rewriter::decryptResults(res, this->rmeta));
...@@ -1701,12 +1731,10 @@ ShowTablesExecutor:: ...@@ -1701,12 +1731,10 @@ ShowTablesExecutor::
nextImpl(const ResType &res, const NextParams &nparams) nextImpl(const ResType &res, const NextParams &nparams)
{ {
reenter(this->corot) { reenter(this->corot) {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
yield return CR_QUERY_AGAIN(nparams.original_query); yield return CR_QUERY_AGAIN(nparams.original_query);
TEST_ErrPkt(res.success(), "show tables failed"); TEST_ErrPkt(res.success(), "show tables failed");
yield { yield {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const std::shared_ptr<const SchemaInfo> &schema = const std::shared_ptr<const SchemaInfo> &schema =
nparams.ps.getSchemaInfo(); nparams.ps.getSchemaInfo();
const DatabaseMeta *const dm = const DatabaseMeta *const dm =
...@@ -1716,10 +1744,8 @@ nextImpl(const ResType &res, const NextParams &nparams) ...@@ -1716,10 +1744,8 @@ nextImpl(const ResType &res, const NextParams &nparams)
std::vector<std::vector<Item *> > new_rows; std::vector<std::vector<Item *> > new_rows;
for (const auto &it : res.rows) { for (const auto &it : res.rows) {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
assert(1 == it.size()); assert(1 == it.size());
for (const auto &table : dm->getChildren()) { for (const auto &table : dm->getChildren()) {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
assert(table.second); assert(table.second);
if (table.second->getAnonTableName() if (table.second->getAnonTableName()
== ItemToString(*it.front())) { == ItemToString(*it.front())) {
...@@ -1731,10 +1757,54 @@ nextImpl(const ResType &res, const NextParams &nparams) ...@@ -1731,10 +1757,54 @@ nextImpl(const ResType &res, const NextParams &nparams)
} }
} }
} }
return CR_RESULTS(ResType(res, new_rows)); return CR_RESULTS(ResType(res, new_rows));
} }
} }
assert(false);
}
std::pair<AbstractQueryExecutor::ResultType, AbstractAnything *>
ShowCreateTableExecutor::
nextImpl(const ResType &res, const NextParams &nparams){
std::cout<<"showCreateTableExecutor"<<std::endl;
//return CR_QUERY_AGAIN(nparams.original_query);
reenter(this->corot) {
yield return CR_QUERY_AGAIN(this->query);
TEST_ErrPkt(res.success(), "show create table tables failed");
yield {
//how to find schemaInfo?? we can get it directly
const std::shared_ptr<const SchemaInfo> &schema =
nparams.ps.getSchemaInfo();
const DatabaseMeta *const dm =
schema->getChild(IdentityMetaKey(nparams.default_db));
TEST_ErrPkt(dm, "failed to find the database '"
+ nparams.default_db + "'");
std::vector<std::vector<Item *> > new_rows;
//adapted from show tables;
/*for (const auto &it : res.rows) {
assert(1 == it.size());
for (const auto &table : dm->getChildren()) {
assert(table.second);
if (table.second->getAnonTableName()
== ItemToString(*it.front())) {
const IdentityMetaKey &plain_table_name
= dm->getKey(*table.second.get());
new_rows.push_back(std::vector<Item *>
{make_item_string(plain_table_name.getValue())});
}
}
}*/
return CR_RESULTS(ResType(res, new_rows));
}
}
//avoid reach the end
assert(false); assert(false);
} }
...@@ -96,15 +96,30 @@ private: ...@@ -96,15 +96,30 @@ private:
class ShowTablesExecutor : public AbstractQueryExecutor { class ShowTablesExecutor : public AbstractQueryExecutor {
const std::vector<std::unique_ptr<Delta> > deltas; const std::vector<std::unique_ptr<Delta> > deltas;
std::string query;
public: public:
ShowTablesExecutor() {} ShowTablesExecutor(){}
~ShowTablesExecutor() {} ~ShowTablesExecutor() {}
std::pair<ResultType, AbstractAnything *> std::pair<ResultType, AbstractAnything *>
nextImpl(const ResType &res, const NextParams &nparams); nextImpl(const ResType &res, const NextParams &nparams);
}; };
//added
class ShowCreateTableExecutor: public AbstractQueryExecutor{
std::string query;
public:
ShowCreateTableExecutor(const LEX &lex):query(lexToQuery(lex)){}
~ShowCreateTableExecutor(){}
std::pair<ResultType, AbstractAnything *>
nextImpl(const ResType &res, const NextParams &nparams);
};
// Abstract base class for query handler. // Abstract base class for query handler.
class DMLHandler : public SQLHandler { class DMLHandler : public SQLHandler {
public: public:
......
...@@ -665,7 +665,6 @@ translatorHelper(std::vector<std::string> texts, ...@@ -665,7 +665,6 @@ translatorHelper(std::vector<std::string> texts,
static bool static bool
buildTypeTextTranslator() buildTypeTextTranslator()
{ {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
// Onions. // Onions.
const std::vector<std::string> onion_strings const std::vector<std::string> onion_strings
{ {
...@@ -988,7 +987,7 @@ static void optimize_select_lex(st_select_lex *select_lex, Analysis & a); ...@@ -988,7 +987,7 @@ static void optimize_select_lex(st_select_lex *select_lex, Analysis & a);
static Item *getLeftExpr(const Item_in_subselect &i) static Item *getLeftExpr(const Item_in_subselect &i)
{ {
Item *const left_expr = Item *const left_expr =
i.*rob<Item_in_subselect, Item*, i.*rob<Item_in_subselect, Item*,
&Item_in_subselect::left_expr>::ptr(); &Item_in_subselect::left_expr>::ptr();
assert(left_expr); assert(left_expr);
...@@ -1194,38 +1193,6 @@ static class ANON : public CItemSubtypeIT<Item_cache, Item::Type::CACHE_ITEM> { ...@@ -1194,38 +1193,6 @@ static class ANON : public CItemSubtypeIT<Item_cache, Item::Type::CACHE_ITEM> {
UNIMPLEMENTED; UNIMPLEMENTED;
return NULL; return NULL;
/*
TEST_TextMessageError(false ==
i->field()->orig_table->alias_name_used,
"Can not mix CACHE_ITEM and table alias.");
const std::string table_name =
std::string(i->field()->orig_table->alias);
const std::string field_name =
std::string(i->field()->field_name);
OnionMeta *const om =
a.getOnionMeta(table_name, field_name, oPLAIN);
if (a.getOnionLevel(om) != SECLEVEL::PLAINVAL) {
const FieldMeta *const fm =
a.getFieldMeta(table_name, field_name);
throw OnionAdjustExcept(oPLAIN, fm, SECLEVEL::PLAINVAL,
table_name);
}
const EncSet out_es = PLAIN_EncSet;
tr = reason(out_es, "is cache item", i);
return new RewritePlan(out_es, tr);
*/
/*
Item *example = i->*rob<Item_cache, Item*, &Item_cache::example>::ptr();
if (example)
return gather(example, tr, a);
return tr.encset;
UNIMPLEMENTED;
return NULL;
*/
} }
virtual Item * do_optimize_type(Item_cache *i, Analysis & a) const virtual Item * do_optimize_type(Item_cache *i, Analysis & a) const
...@@ -1347,7 +1314,6 @@ Rewriter::dispatchOnLex(Analysis &a, const std::string &query) ...@@ -1347,7 +1314,6 @@ Rewriter::dispatchOnLex(Analysis &a, const std::string &query)
// optimization: do not process queries that we will not rewrite // optimization: do not process queries that we will not rewrite
if (noRewrite(*lex)) { if (noRewrite(*lex)) {
std::cout<<"we return SimpleExecutor here"<<__FILE__<<":"<<__LINE__<<std::endl;
return new SimpleExecutor(); return new SimpleExecutor();
} else if (dml_dispatcher->canDo(lex)) { } else if (dml_dispatcher->canDo(lex)) {
// HACK: We don't want to process INFORMATION_SCHEMA queries // HACK: We don't want to process INFORMATION_SCHEMA queries
......
...@@ -33,8 +33,7 @@ rewrite(const Item &i, const EncSet &req_enc, Analysis &a) { ...@@ -33,8 +33,7 @@ rewrite(const Item &i, const EncSet &req_enc, Analysis &a) {
} }
TABLE_LIST * TABLE_LIST *
rewrite_table_list(const TABLE_LIST * const t, const Analysis &a) rewrite_table_list(const TABLE_LIST * const t, const Analysis &a) {
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl; std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
// Table name can only be empty when grouping a nested join. // Table name can only be empty when grouping a nested join.
assert(t->table_name || t->nested_join); assert(t->table_name || t->nested_join);
...@@ -153,14 +152,12 @@ gather(const Item &i, Analysis &a) ...@@ -153,14 +152,12 @@ gather(const Item &i, Analysis &a)
void void
gatherAndAddAnalysisRewritePlan(const Item &i, Analysis &a) gatherAndAddAnalysisRewritePlan(const Item &i, Analysis &a)
{ {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
a.rewritePlans[&i] = std::unique_ptr<RewritePlan>(gather(i, a)); a.rewritePlans[&i] = std::unique_ptr<RewritePlan>(gather(i, a));
} }
std::vector<std::tuple<std::vector<std::string>, Key::Keytype> > std::vector<std::tuple<std::vector<std::string>, Key::Keytype> >
collectKeyData(const LEX &lex) collectKeyData(const LEX &lex)
{ {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
std::vector<std::tuple<std::vector<std::string>, Key::Keytype> > output; std::vector<std::tuple<std::vector<std::string>, Key::Keytype> > output;
auto key_it = auto key_it =
...@@ -295,8 +292,9 @@ rewrite_key(const TableMeta &tm, const Key &key, const Analysis &a) ...@@ -295,8 +292,9 @@ rewrite_key(const TableMeta &tm, const Key &key, const Analysis &a)
const std::vector<onion> key_onions = getOnionIndexTypes(); const std::vector<onion> key_onions = getOnionIndexTypes();
for (auto onion_it : key_onions) { for (auto onion_it : key_onions) {
const onion o = onion_it; const onion o = onion_it;
THD* cthd = current_thd;
//原始key的拷贝 //原始key的拷贝
Key *const new_key = key.clone(current_thd->mem_root); Key *const new_key = key.clone(cthd->mem_root);
//通过key的原始名字+onion+tm哈希获得新的key名字,用的是std::hash<string>算法. //通过key的原始名字+onion+tm哈希获得新的key名字,用的是std::hash<string>算法.
// Set anonymous name. // Set anonymous name.
const std::string new_name = const std::string new_name =
......
...@@ -494,6 +494,7 @@ next(lua_State *const L) { ...@@ -494,6 +494,7 @@ next(lua_State *const L) {
nilBuffer(L, 1); nilBuffer(L, 1);
return 5; return 5;
} }
WrapperState *const c_wrapper = clients[client]; WrapperState *const c_wrapper = clients[client];
assert(EXECUTE_QUERIES); assert(EXECUTE_QUERIES);
......
...@@ -940,7 +940,19 @@ operator<<(std::ostream &out, LEX &lex) ...@@ -940,7 +940,19 @@ operator<<(std::ostream &out, LEX &lex)
/* placeholders to make analysis work.. */ /* placeholders to make analysis work.. */
out << ".. type " << lex.sql_command << " query .."; out << ".. type " << lex.sql_command << " query ..";
break; break;
//ADDED
case SQLCOM_SHOW_CREATE:{
int elements = lex.select_lex.table_list.elements;
if(elements==1){
TABLE_LIST *tbl = lex.select_lex.table_list.first;
std::string db(tbl->db);
std::string tbn(tbl->table_name);
out<< "SHOW CREATE TABLE "+db+"."+tbn;
}else{
out<<"ONLY SUPPORT ONE TABLE";
}
break;
}
default: default:
thrower() << "unhandled sql command " << lex.sql_command; thrower() << "unhandled sql command " << lex.sql_command;
} }
......
/t/mysql-src/build/client/mysql -uroot -pletmein -h 127.0.0.1 -P3399
[mysql-proxy]
plugins = proxy
event-threads = 4
proxy-lua-script = /t/cryt/mysqlproxy/wrapper.lua
proxy-address = 127.0.0.1:3399
proxy-backen-addresses = 127.0.0.1:3306
[mysql-proxy]
plugins = proxy
event-threads = 4
proxy-lua-script = /t/cryt/tutorial-basic.lua
proxy-address = 127.0.0.1:3399
proxy-backen-addresses = 127.0.0.1:3306
mysql-proxy --defaults-file=./mysql-proxy2.cnf
rm -rf ./shadow/* ./shadowtest/*
mysql -uroot -pletmein < reset.sql
drop database if exists tf;
drop database if exists tdb;
drop database if exists tdb2;
drop database if exists tdb3;
drop database if exists remote_db;
drop database if exists cryptdb_udf;
mysql-proxy --defaults-file=/t/cryt/mysql-proxy.cnf
./obj/main/cdb_test
COLOR_END = '\027[00m'
function redtext(x)
return '\027[1;31m' .. x .. COLOR_END
end
function greentext(x)
return '\027[1;92m'.. x .. COLOR_END
end
function orangetext(x)
return '\027[01;33m'.. x .. COLOR_END
end
g=1
queryType = {}
queryType[proxy.COM_SLEEP] = "COM_SLEEP"
queryType[proxy.COM_QUIT] = "COM_QUIT"
queryType[proxy.COM_INIT_DB] = "COM_INIT_DB"
queryType[proxy.COM_QUERY] = "COM_QUERY"
queryType[proxy.COM_FIELD_LIST]= "COM_FIELD_LIST"
queryType[proxy.COM_CREATE_DB]= "COM_CREATE_DB"
queryType[proxy.COM_DROP_DB]= "COM_DROP_DB"
queryType[proxy.COM_REFRESH]= "COM_REFRESH"
queryType[proxy.COM_SHUTDOWN] = "COM_SHUTDOWN"
queryType[proxy.COM_STATISTICS] = "COM_STATISTICS"
queryType[proxy.COM_PROCESS_INFO] = "COM_PROCESS_INFO"
queryType[proxy.COM_CONNECT] = "COM_CONNECT"
queryType[proxy.COM_PROCESS_KILL] = "COM_PROCESS_KILL"
queryType[proxy.COM_DEBUG] = "COM_DEBUG"
queryType[proxy.COM_PING] = "COM_PING"
queryType[proxy.COM_TIME] = "COM_TIME"
queryType[proxy.COM_DELAYED_INSERT] = "COM_DELAYED_INSERT"
queryType[proxy.COM_CHANGE_USER] = "COM_CHANGE_USER"
queryType[proxy.COM_BINLOG_DUMP] = "COM_BINLOG_DUMP"
queryType[proxy.COM_TABLE_DUMP] = "COM_TABLE_DUMP"
queryType[proxy.COM_CONNECT_OUT] = "COM_CONNECT_OUT"
queryType[proxy.COM_REGISTER_SLAVE] = "COM_REGISTER_SLAVE"
queryType[proxy.COM_STMT_PREPARE] = "COM_STMT_PREPARE"
queryType[proxy.COM_STMT_EXECUTE] = "COM_STMT_EXECUTE"
queryType[proxy.COM_STMT_SEND_LONG_DATA] = "COM_STMT_SEND_LONG_DATA"
queryType[proxy.COM_STMT_CLOSE] = "COM_STMT_CLOSE"
queryType[proxy.COM_STMT_RESET] = "COM_STMT_RESET"
queryType[proxy.COM_SET_OPTION] = "COM_SET_OPTION"
queryType[proxy.COM_STMT_FETCH] = "COM_STMT_FETCH"
queryType[proxy.COM_DAEMON] = "COM_DAEMON"
function printCS()
server = nil
client = nil
sp = nil
if proxy.connection.client ~= nil then
client = proxy.connection.client.src.name
end
if proxy.connection.server ~= nil then
server = proxy.connection.server.dst.address
sp = proxy.connection.server.dst.port
end
if client~= nil then
print(redtext("clientName:"..client))
else
print(redtext("clientName=nil"))
end
if server ~= nil then
print(redtext(server))
else
print(redtext("server=nil"))
end
if sp ~= nil then
print(redtext(sp))
else
print(redtext("sp = nil"))
end
end
function connect_server()
print(orangetext("connect_server"))
printCS()
if g == 1 then
g = 0
else g = 1
end
print("g "..g)
print("ndx "..proxy.connection.backend_ndx.."get: "..#proxy.global.backends)
end
function read_handshake()
print(orangetext("read_handshake"))
printCS()
end
function read_auth()
print(orangetext("read_auth"))
printCS()
end
function read_auth_result()
print(orangetext("read_auth_result"))
printCS()
end
function read_query( packet )
print(orangetext("read_query"))
print(redtext("query type: "..queryType[string.byte(packet)]))
printCS()
if string.byte(packet) == proxy.COM_QUERY then
print("we got a normal query: " .. string.sub(packet, 2))
proxy.queries:append(1, packet, {resultset_is_needed = true})
return proxy.PROXY_SEND_QUERY
else
print("we got a abnormal query: " .. string.sub(packet, 2))
end
end
function print_fields(infields)
local resfields = infields
local interim_fields = {}
--store fileds in interim_fields
if (#resfields) then
io.write("|")
end
for i = 1, #resfields do
rfi = resfields[i]
interim_fields[i] ={ type = resfields[i].type,name = resfields[i].name }
io.write(string.format("%-20s|",rfi.name))
end
end
function print_rows(inrows)
local resrows = inrows
local interim_rows = {}
for row in resrows do
table.insert(interim_rows, row)
io.write("|")
-- for key,value in pairs(row) do
-- io.write(string.format("%-20s|", value))
-- end
for k,v in pairs(row) do
if v ~= nil then
io.write(string.format("%-20s|", v))
io.write("size = "..string.len(v))
else
io.write(string.format("%-20s|", "nil"))
end
end
print()
end
end
function read_query_result(inj)
print(orangetext("read_query_result"))
printCS()
print("ROWS: "..type(inj.resultset.rows))
if inj.resultset.rows ~= nil then
print_fields(inj.resultset.fields)
print("finish fields")
print_rows(inj.resultset.rows)
end
end
This diff is collapsed.
...@@ -4,6 +4,8 @@ UTILSRC := onions.cc cryptdb_log.cc ctr.cc util.cc version.cc ...@@ -4,6 +4,8 @@ UTILSRC := onions.cc cryptdb_log.cc ctr.cc util.cc version.cc
all: $(OBJDIR)/libedbutil.so $(OBJDIR)/libedbutil.a all: $(OBJDIR)/libedbutil.so $(OBJDIR)/libedbutil.a
$(OBJDIR)/libedbutil.so: $(patsubst %.cc,$(OBJDIR)/util/%.o,$(UTILSRC)) $(OBJDIR)/libedbutil.so: $(patsubst %.cc,$(OBJDIR)/util/%.o,$(UTILSRC))
echo $@ $^
echo '####################################################'
$(CXX) -shared -o $@ $^ $(LDFLAGS) -lntl -lcrypto -lgmp $(CXX) -shared -o $@ $^ $(LDFLAGS) -lntl -lcrypto -lgmp
$(OBJDIR)/libedbutil.a: $(patsubst %.cc,$(OBJDIR)/util/%.o,$(UTILSRC)) $(OBJDIR)/libedbutil.a: $(patsubst %.cc,$(OBJDIR)/util/%.o,$(UTILSRC))
......
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