Commit ee6f5ee6 authored by yiwenshao's avatar yiwenshao

remove executor completely

parent 2157bfe0
...@@ -17,6 +17,12 @@ To make this work properly, you should at least make sure that the database tdb ...@@ -17,6 +17,12 @@ To make this work properly, you should at least make sure that the database tdb
static std::string embeddedDir="/t/cryt/shadow"; static std::string embeddedDir="/t/cryt/shadow";
struct help_select{
ReturnMeta rmeta;
std::string query;
};
SharedProxyState *shared_ps; SharedProxyState *shared_ps;
Connect *globalConn; Connect *globalConn;
ProxyState *ps; ProxyState *ps;
...@@ -34,44 +40,30 @@ void parseResType(const ResType &rd) { ...@@ -34,44 +40,30 @@ void parseResType(const ResType &rd) {
} }
} }
static void sp_next_second(std::string db, std::string query, QueryRewrite *qr,ResType inRes){ static void sp_next_second(std::string db, std::string query,const help_select & hs,ResType inRes){
ps->safeCreateEmbeddedTHD(); ps->safeCreateEmbeddedTHD();
const ResType &resin = inRes; const ResType &resin = inRes;
try{ try{
//AbstractQueryExecutor::ResultType::RESULTS //AbstractQueryExecutor::ResultType::RESULTS
NextParams nparams(*ps,db,query); NextParams nparams(*ps,db,query);
nparams.ps.getSchemaCache().updateStaleness(nparams.ps.getEConn(),false); nparams.ps.getSchemaCache().updateStaleness(nparams.ps.getEConn(),false);
const auto &res = decryptResults(resin,hs.rmeta);
// const auto &new_results = qr->executor->next(res, nparams);
//const auto &result_type = new_results.first;
// const auto &res = new_results.second->extract<ResType>();
const auto &res = decryptResults(resin,((DMLQueryExecutor*)(qr->executor).get())->getReturnMeta());
parseResType(res); parseResType(res);
}catch(...){ }catch(...){
std::cout<<"second next error"<<std::endl; std::cout<<"second next error"<<std::endl;
} }
} }
static void sp_next_first(std::string db, std::string query, QueryRewrite *qr,ResType inRes){ static void sp_next_first(std::string db, std::string query,const help_select &hs){
ps->safeCreateEmbeddedTHD(); ps->safeCreateEmbeddedTHD();
// const ResType &res = inRes;
try{ try{
//AbstractQueryExecutor::ResultType::QUERY_COME_AGAIN //AbstractQueryExecutor::ResultType::QUERY_COME_AGAIN
NextParams nparams(*ps,db,query); NextParams nparams(*ps,db,query);
nparams.ps.getSchemaCache().updateStaleness(nparams.ps.getEConn(),false); nparams.ps.getSchemaCache().updateStaleness(nparams.ps.getEConn(),false);
const std::string next_query = ((DMLQueryExecutor*)(qr->executor).get())->getQuery(); const std::string next_query = hs.query;
//x const auto &new_results = qr->executor->next(res, nparams);
//x const auto &output =
//x std::get<1>(new_results)->extract<std::pair<bool, std::string> >();
//x const auto &next_query = output.second;
//here we execute the query against the remote database, and get rawReturnValue
rawMySQLReturnValue resRemote = executeAndGetResultRemote(globalConn,next_query); rawMySQLReturnValue resRemote = executeAndGetResultRemote(globalConn,next_query);
//transform rawReturnValue first
const auto &againGet = MygetResTypeFromLuaTable(false,&resRemote); const auto &againGet = MygetResTypeFromLuaTable(false,&resRemote);
sp_next_second(db,query,qr,againGet); sp_next_second(db,query,hs,againGet);
}catch(...){ }catch(...){
std::cout<<"first next error"<<std::endl; std::cout<<"first next error"<<std::endl;
} }
...@@ -239,14 +231,17 @@ my_rewrite_select_lex(const st_select_lex &select_lex, Analysis &a){ ...@@ -239,14 +231,17 @@ my_rewrite_select_lex(const st_select_lex &select_lex, Analysis &a){
static static
AbstractQueryExecutor * my_rewrite_select(Analysis &a, LEX *lex){ help_select my_rewrite_select(Analysis &a, LEX *lex){
LEX *const new_lex = copyWithTHD(lex); LEX *const new_lex = copyWithTHD(lex);
//this is actually table list instead of join list. //this is actually table list instead of join list.
new_lex->select_lex.top_join_list = new_lex->select_lex.top_join_list =
rewrite_table_list(lex->select_lex.top_join_list, a); rewrite_table_list(lex->select_lex.top_join_list, a);
SELECT_LEX *const select_lex_res = my_rewrite_select_lex(new_lex->select_lex, a); SELECT_LEX *const select_lex_res = my_rewrite_select_lex(new_lex->select_lex, a);
set_select_lex(new_lex,select_lex_res); set_select_lex(new_lex,select_lex_res);
return new DMLQueryExecutor(*new_lex, a.rmeta); help_select hs;
hs.query = lexToQuery(*new_lex);
hs.rmeta = a.rmeta;
return hs;
} }
...@@ -278,9 +273,9 @@ static void testCreateTableHandler(std::string query,std::string db="tdb"){ ...@@ -278,9 +273,9 @@ static void testCreateTableHandler(std::string query,std::string db="tdb"){
LEX *const lex = p->lex(); LEX *const lex = p->lex();
std::string table(lex->select_lex.table_list.first->table_name); std::string table(lex->select_lex.table_list.first->table_name);
my_gather_select(analysis,lex); my_gather_select(analysis,lex);
auto executor = my_rewrite_select(analysis,lex); help_select hs = my_rewrite_select(analysis,lex);
QueryRewrite *qr = new QueryRewrite(QueryRewrite(true, analysis.rmeta, analysis.kill_zone, executor)); //QueryRewrite *qr = new QueryRewrite(QueryRewrite(true, analysis.rmeta, analysis.kill_zone, executor));
sp_next_first(db,query,qr,MygetResTypeFromLuaTable(true)); sp_next_first(db,query,hs);
} }
int int
......
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