Commit ab3b448f authored by yiwenshao's avatar yiwenshao

add field sql_type to FieldMeta

parent 9c993074
File added
......@@ -32,10 +32,10 @@ $(OBJDIR)/libcryptdb.so: $(CRYPTDB_OBJS) \
#install: install_main
install: install_main
#.PHONY: install_main
#install_main: $(OBJDIR)/libcryptdb.so
# install -m 644 $(OBJDIR)/libcryptdb.so /usr/lib
.PHONY: install_main
install_main: $(OBJDIR)/libcryptdb.so
install -m 644 $(OBJDIR)/libcryptdb.so /usr/lib
# vim: set noexpandtab:
......@@ -160,7 +160,7 @@ void InsertHandler::gather(Analysis &a, LEX *const lex) const {
// Values
// -----------------
if (lex->many_values.head()) {
//开始处理many values
//start processing many values
auto it = List_iterator<List_item>(lex->many_values);
List<List_item> newList;
for (;;) {
......@@ -178,7 +178,7 @@ void InsertHandler::gather(Analysis &a, LEX *const lex) const {
// > INSERT INTO <table> () VALUES ();
// > INSERT INTO <table> VALUES ();
} else {
//li指向了lex->many_values的迭代内容
//li pointer to items of lex->many_values
auto it0 = List_iterator<Item>(*li);
auto fmVecIt = fmVec.begin();
......@@ -188,8 +188,8 @@ void InsertHandler::gather(Analysis &a, LEX *const lex) const {
if (!i) {
break;
}
//获得values中的内容,并且通过fieldMeta好帮助完成rewrite工作
//每个field都要进行洋葱的加密.
//fetch values, and use fieldMeta to facilitate rewrite
//every filed should be encrypted with onions of encryption
rewriteInsertHelper(*i, **fmVecIt, a, newList0);
++fmVecIt;
}
......@@ -202,8 +202,7 @@ void InsertHandler::gather(Analysis &a, LEX *const lex) const {
new_lex->many_values = newList;
}
//对于普通的insert, 这部分的内容不会用到的.
//for queries with ON DUPLICATE KEY UPDATE
// -----------------------
// ON DUPLICATE KEY UPDATE
// -----------------------
......
......@@ -308,7 +308,8 @@ static std::unique_ptr<SchemaInfo> myLoadSchemaInfo() {
//load all metadata and then store it in schema
loadChildren(schema.get());
Analysis analysis(std::string("student"),*schema,std::unique_ptr<AES_KEY>(getKey(std::string("113341234"))),
Analysis analysis(std::string("student"),*schema,
std::unique_ptr<AES_KEY>(getKey(std::string("113341234"))),
SECURITY_RATING::SENSITIVE);
return schema;
}
......@@ -652,7 +653,6 @@ static meta_file load_meta(string db="tdb", string table="student", string filen
return res;
}
static void write_row_data(rawMySQLReturnValue& resraw,string db, string table){
vector<FILE*> data_files;
string prefix = string("data/")+db+"/"+table+"/";
......@@ -835,8 +835,10 @@ static void construct_insert(rawMySQLReturnValue & str,std::string table,std::ve
if(IS_NUM(str.fieldTypes[j])) {
cout<<str.fieldTypes[j]<<endl;
cur+=str.rowValues[i][j]+=",";
cout<<"isnum"<<endl;
}else{
cur+=string("\"")+=str.rowValues[i][j]+="\",";
cout<<"notnum"<<endl;
}
}
cur.back()=')';
......@@ -862,12 +864,12 @@ main(int argc, char* argv[]) {
}
init();
std::string option(argv[1]);
std::string db="tdb2",table="stu";
std::string db="tdb",table="student";
if(option=="store"){
store(db,table);
}else if(option == "load"){
auto res = load_files(db,table);
ResType res = load_files(db,table);
rawMySQLReturnValue str;
add(str,res);
std::vector<string> res_query;
......
......@@ -226,7 +226,7 @@ std::unique_ptr<FieldMeta>
FieldMeta::deserialize(unsigned int id, const std::string &serial) {
assert(id != 0);
const auto vec = unserialize_string(serial);
assert(9 == vec.size());
assert(10 == vec.size());//We add one item,so there are ten items now
const std::string fname = vec[0];
const bool has_salt = string_to_bool(vec[1]);
......@@ -239,10 +239,13 @@ FieldMeta::deserialize(unsigned int id, const std::string &serial) {
const bool has_default = string_to_bool(vec[7]);
const std::string default_value = vec[8];
enum enum_field_types sql_type = ((enum enum_field_types)atoi(vec[9].c_str()));//new field added
return std::unique_ptr<FieldMeta>
(new FieldMeta(id, fname, has_salt, salt_name, onion_layout,
sec_rating, uniq_count, counter, has_default,
default_value));
default_value,sql_type));
}
// first element is the levels that the onionmeta should implement
......@@ -333,7 +336,7 @@ FieldMeta::FieldMeta(const Create_field &field,
sec_rating(sec_rating), uniq_count(uniq_count), counter(0),
has_default(determineHasDefault(field)),
default_value(determineDefaultValue(has_default, field)) {
sql_type = field.sql_type;//added by shaoyiwen
TEST_TextMessageError(init_onions_layout(m_key, this, field, unique),
"Failed to build onions for new FieldMeta!");
}
......@@ -343,6 +346,7 @@ std::string FieldMeta::serialize(const DBObject &parent) const
const std::string &serialized_salt_name =
true == this->has_salt ? serialize_string(getSaltName())
: serialize_string("");
std::string sql_type_string = std::to_string((int)sql_type);
const std::string serial =
serialize_string(fname) +
serialize_string(bool_to_string(has_salt)) +
......@@ -352,7 +356,8 @@ std::string FieldMeta::serialize(const DBObject &parent) const
serialize_string(std::to_string(uniq_count)) +
serialize_string(std::to_string(counter)) +
serialize_string(bool_to_string(has_default)) +
serialize_string(default_value);
serialize_string(default_value) +
serialize_string(sql_type_string);//added by shaoyiwen
return serial;
}
......
......@@ -99,12 +99,13 @@ public:
const std::string &salt_name, onionlayout onion_layout,
SECURITY_RATING sec_rating, unsigned long uniq_count,
uint64_t counter, bool has_default,
const std::string &default_value)
const std::string &default_value,
enum enum_field_types in_sql_type)
: MappedDBMeta(id), fname(fname), salt_name(salt_name),
onion_layout(onion_layout), has_salt(has_salt),
sec_rating(sec_rating), uniq_count(uniq_count),
counter(counter), has_default(has_default),
default_value(default_value) {
default_value(default_value),sql_type(in_sql_type) {
}
~FieldMeta() {;}
......@@ -144,7 +145,11 @@ private:
const bool has_default;
const std::string default_value;
//added
enum enum_field_types sql_type;
SECLEVEL getOnionLevel(onion o) const;
enum_field_types getSqlType(){return sql_type;}
static onionlayout determineOnionLayout(const AES_KEY *const m_key,
const Create_field &f,
......
......@@ -9,11 +9,11 @@ $(OBJDIR)/libedbutil.so: $(patsubst %.cc,$(OBJDIR)/util/%.o,$(UTILSRC))
$(OBJDIR)/libedbutil.a: $(patsubst %.cc,$(OBJDIR)/util/%.o,$(UTILSRC))
$(AR) r $@ $^
#install: install_util
install: install_util
#.PHONY: install_util
#install_util: $(OBJDIR)/libedbutil.so
# install -m 644 $(OBJDIR)/libedbutil.so /usr/lib
.PHONY: install_util
install_util: $(OBJDIR)/libedbutil.so
install -m 644 $(OBJDIR)/libedbutil.so /usr/lib
$(OBJDIR)/util/version.cc: always
@mkdir -p $(@D)
......
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