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