Commit a2673803 authored by yiwenshao's avatar yiwenshao

able to use ashe for both agg query and normal query

parent 3695a861
......@@ -5,8 +5,8 @@
[onions for num]
#oDET: DET RND
#oOPE: OPE RND
oAGG: HOM
#oASHE: ASHE
#oAGG: HOM
oASHE: ASHE
[end]
......
......@@ -195,8 +195,8 @@ OLK EncSet::extract_singleton() const
static bool
needsSalt(SECLEVEL l)
{
// return l == SECLEVEL::RND||l==SECLEVEL::ASHE;
return l == SECLEVEL::RND;
return l == SECLEVEL::RND||l==SECLEVEL::ASHE;
// return l == SECLEVEL::RND;
}
bool
......
......@@ -666,7 +666,8 @@ rewrite_proj(const Item &i, const RewritePlan &rp, Analysis &a,
//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());
bool use_salt = needsSalt(olk.get());
if(i.type()==Item::SUM_FUNC_ITEM) use_salt=false;
// This line implicity handles field aliasing for at least some cases.
// As i->name can/will be the alias.
......@@ -1648,12 +1649,10 @@ nextImpl(const ResType &res, const NextParams &nparams)
std::pair<AbstractQueryExecutor::ResultType, AbstractAnything *>
ShowTablesExecutor::
nextImpl(const ResType &res, const NextParams &nparams)
{
nextImpl(const ResType &res, const NextParams &nparams){
reenter(this->corot) {
yield return CR_QUERY_AGAIN(nparams.original_query);
TEST_ErrPkt(res.success(), "show tables failed");
yield {
const std::shared_ptr<const SchemaInfo> &schema =
nparams.ps.getSchemaInfo();
......@@ -1662,14 +1661,12 @@ nextImpl(const ResType &res, const NextParams &nparams)
TEST_ErrPkt(dm, "failed to find the database '"
+ nparams.default_db + "'");
std::vector<std::vector<Item *> > new_rows;
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 *>
......
......@@ -907,8 +907,7 @@ do_optimize_const_item(T *i, Analysis &a) {
//Layers of decryption
static Item *
decrypt_item_layers(const Item &i, const FieldMeta *const fm, onion o,
uint64_t IV)
{
uint64_t IV) {
assert(!RiboldMYSQL::is_null(i));
const Item *dec = &i;
Item *out_i = NULL;
......@@ -919,8 +918,12 @@ decrypt_item_layers(const Item &i, const FieldMeta *const fm, onion o,
const auto &enc_layers = om->getLayers();
for (auto it = enc_layers.rbegin(); it != enc_layers.rend(); ++it) {
if(o==oASHE) {
if(dec->type()!=Item::INT_ITEM){
out_i = ((ASHE&)(*it)).decrypt_sum(*dec);
break;
}else{
out_i = (*it)->decrypt(*dec,IV);
}
}
out_i = (*it)->decrypt(*dec, IV);
assert(out_i);
......@@ -1402,16 +1405,12 @@ std::string ReturnMeta::stringify() {
*
*/
ResType
Rewriter::decryptResults(const ResType &dbres, const ReturnMeta &rmeta)
{
Rewriter::decryptResults(const ResType &dbres, const ReturnMeta &rmeta) {
assert(dbres.success());
const unsigned int rows = dbres.rows.size();
const unsigned int cols = dbres.names.size();
// un-anonymize the names
std::vector<std::string> dec_names;
for (auto it = dbres.names.begin();
it != dbres.names.end(); it++) {
const unsigned int index = it - dbres.names.begin();
......@@ -1422,14 +1421,12 @@ Rewriter::decryptResults(const ResType &dbres, const ReturnMeta &rmeta)
dec_names.push_back(rf.fieldCalled());
}
}
const unsigned int real_cols = dec_names.size();
std::vector<std::vector<Item *> > dec_rows(rows);
for (unsigned int i = 0; i < rows; i++) {
dec_rows[i] = std::vector<Item *>(real_cols);
}
//
//fields
unsigned int col_index = 0;
for (unsigned int c = 0; c < cols; c++) {
const ReturnField &rf = rmeta.rfmeta.at(c);
......@@ -1437,9 +1434,7 @@ Rewriter::decryptResults(const ResType &dbres, const ReturnMeta &rmeta)
continue;
}
FieldMeta *const fm = rf.getOLK().key;
for (unsigned int r = 0; r < rows; r++) {
if (!fm || dbres.rows[r][c]->is_null()) {
dec_rows[r][col_index] = dbres.rows[r][c];
} else {
......
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