Commit d595569b authored by yiwenshao's avatar yiwenshao

add sumUDA to ASHE in CryptoHandler.cc

parent 793fa1ca
......@@ -1334,20 +1334,6 @@ static udf_func u_sum_a = {
NULL,
0L,
};
static udf_func u_sumashe_a = {
LEXSTRING("cryptdb_asheagg"),
STRING_RESULT,
UDFTYPE_AGGREGATE,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
0L,
};
static udf_func u_sum_f = {
LEXSTRING("cryptdb_func_add_set"),
......@@ -1610,6 +1596,21 @@ static udf_func u_cryptdb_version = {
0L,
};
static udf_func u_sumashe_a = {
LEXSTRING("cryptdb_asheagg"),
STRING_RESULT,
UDFTYPE_AGGREGATE,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
0L,
};
const std::vector<udf_func*> udf_list = {
&u_decRNDInt,
&u_decRNDString,
......@@ -1625,6 +1626,8 @@ const std::vector<udf_func*> udf_list = {
/************************************************ASHE********************************************/
ASHE::ASHE(unsigned int id, const std::string &serial):ashe(1){}
/*the type of filed after the ASHE layer is used.*/
......@@ -1662,6 +1665,16 @@ ASHE::decrypt(const Item &ctext, uint64_t IV) const
Item_int(static_cast<ulonglong>(res));
}
Item *
ASHE::sumUDA(Item *const expr) const
{
List<Item> l;
l.push_back(expr);
// l.push_back(ZZToItemStr(sk->hompubkey()));
return new (current_thd->mem_root) Item_func_udf_str(&u_sumashe_a, l);
}
ASHE::~ASHE() {
}
......
......@@ -199,6 +199,8 @@ public:
//TODO needs multi encrypt and decrypt
Item *encrypt(const Item &p, uint64_t IV) const;
Item * decrypt(const Item &c, uint64_t IV) const;
Item * sumUDA(Item *const expr) const;
protected:
std::string const seed_key;
mutable RAW_ASHE ashe;
......
......@@ -647,7 +647,7 @@ addSaltToReturn(ReturnMeta *const rm, int pos)
rm->rfmeta.insert(pair);
}
//Item是当前需要加密的item, rp是gather阶段存入的RewritePlain,加密的结果放在newList中, Analysis用于辅助分析.
//Item needs to be encrypted using the RewritePlain from the gather phase. The results will be put in newList, and Analysis is helper class.
static void
rewrite_proj(const Item &i, const RewritePlan &rp, Analysis &a,
List<Item> *const newList) {
......@@ -661,7 +661,7 @@ rewrite_proj(const Item &i, const RewritePlan &rp, Analysis &a,
ir = cached_rewritten_i->second.first;
olk = cached_rewritten_i->second.second;
} else {
//对于select中的选择域来说,这里对应的是rewrite_field.cc中的83, do_rewrite_type
//rewrite=>do_rewrite_type for Item of type FIELD_ITEM
ir = rewrite(i, rp.es_out, a);
olk = rp.es_out.chooseOne();
}
......@@ -669,7 +669,8 @@ rewrite_proj(const Item &i, const RewritePlan &rp, Analysis &a,
ir = rewrite(i, rp.es_out, a);
olk = rp.es_out.chooseOne();
}
//和insert不同, select的时候, 只要一个洋葱, 选取一个进行改写就可以了, 不需要扩展.
//Different form INSERT, SELECT needs only one onion.
assert(ir.assigned() && ir.get());
newList->push_back(ir.get());
const bool use_salt = needsSalt(olk.get());
......
......@@ -2,6 +2,13 @@
#include "test_parser_helper/showselect_lex.hh"
#include "test_parser_helper/showparser.hh"
#include "test_parser_helper/showitem.hh"
static void
show_order(const SQL_I_List<ORDER> &lst) {
for (const ORDER *o = lst.first; o; o = o->next) {
}
}
static void
show_table_joins_and_derived(const List<TABLE_LIST> &tll) {
List_iterator<TABLE_LIST> join_it =
......@@ -63,5 +70,15 @@ show_select_lex(const st_select_lex &select_lex) {
std::cout<<SHOW::ITEM::trans[item->type()]<<std::endl;
show_item(item);
}
//fielter
if(select_lex.where) {
}
if(select_lex.having) {
}
show_order(select_lex.group_list);
show_order(select_lex.order_list);
}
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