Commit 9dcd9f88 authored by Casualet's avatar Casualet

tweak format

parent 214227cd
...@@ -295,7 +295,6 @@ dropAll(const std::unique_ptr<Connect> &conn) ...@@ -295,7 +295,6 @@ dropAll(const std::unique_ptr<Connect> &conn)
std::vector<std::string> std::vector<std::string>
getAllUDFs() getAllUDFs()
{ {
//std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
std::vector<std::string> udfs; std::vector<std::string> udfs;
for (const udf_func * const u: udf_list) { for (const udf_func * const u: udf_list) {
std::stringstream ss; std::stringstream ss;
...@@ -311,11 +310,6 @@ getAllUDFs() ...@@ -311,11 +310,6 @@ getAllUDFs()
udfs.push_back(ss.str()); udfs.push_back(ss.str());
} }
return udfs; return udfs;
} }
...@@ -403,9 +397,8 @@ SharedProxyState::SharedProxyState(ConnectionInfo ci, ...@@ -403,9 +397,8 @@ SharedProxyState::SharedProxyState(ConnectionInfo ci,
assert(loadStoredProcedures(conn)); assert(loadStoredProcedures(conn));
} }
SharedProxyState::~SharedProxyState() SharedProxyState::~SharedProxyState() {
{
// mysql_library_end();
} }
int int
......
...@@ -7,7 +7,7 @@ CRYPTDB_SRCS := schema.cc Translator.cc Connect.cc \ ...@@ -7,7 +7,7 @@ CRYPTDB_SRCS := schema.cc Translator.cc Connect.cc \
rewrite_func.cc rewrite_sum.cc metadata_tables.cc \ rewrite_func.cc rewrite_sum.cc metadata_tables.cc \
error.cc stored_procedures.cc rewrite_ds.cc rewrite_main.cc error.cc stored_procedures.cc rewrite_ds.cc rewrite_main.cc
CRYPTDB_PROGS:= CRYPTDB_PROGS:= cdb_test
CRYPTDBPROGOBJS := $(patsubst %,$(OBJDIR)/main/%,$(CRYPTDB_PROGS)) CRYPTDBPROGOBJS := $(patsubst %,$(OBJDIR)/main/%,$(CRYPTDB_PROGS))
......
...@@ -14,17 +14,14 @@ ...@@ -14,17 +14,14 @@
// TODO: Make length longer. // TODO: Make length longer.
// TODO: Ensure some level of collision resistance. // TODO: Ensure some level of collision resistance.
std::string std::string
getpRandomName() getpRandomName(){
{
// FIXME: Not using numbers because. // FIXME: Not using numbers because.
// 'CREATE TABLE a (2e integer); <---- succeeds // 'CREATE TABLE a (2e integer); <---- succeeds
// 'CREATE TABLE b (2e5 integer); <--- fails // 'CREATE TABLE b (2e5 integer); <--- fails
static const char valids[] = static const char valids[] =
// "0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"; "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static int out_length = 10; static int out_length = 10;
char output[out_length + 1]; char output[out_length + 1];
std::function<bool()> wrap_srand =[](){srand(time(NULL)); return true;}; std::function<bool()> wrap_srand =[](){srand(time(NULL)); return true;};
std::function<void(bool)> do_nothing = [] (bool b) {return;}; std::function<void(bool)> do_nothing = [] (bool b) {return;};
static bool danger_will_robinson = wrap_srand(); static bool danger_will_robinson = wrap_srand();
...@@ -34,14 +31,12 @@ getpRandomName() ...@@ -34,14 +31,12 @@ getpRandomName()
output[i] = valids[rand() % strlen(valids)]; output[i] = valids[rand() % strlen(valids)];
} }
output[out_length] = 0; output[out_length] = 0;
return std::string(output); return std::string(output);
} }
std::string std::string
nextAutoInc(std::map<std::string, unsigned int > & autoInc, nextAutoInc(std::map<std::string, unsigned int > & autoInc,
std::string fullname) std::string fullname){
{
std::string val; std::string val;
if (autoInc.find(fullname) == autoInc.end()) { if (autoInc.find(fullname) == autoInc.end()) {
val = "1"; val = "1";
...@@ -61,7 +56,6 @@ getTableSalt(std::string anonTableName) { ...@@ -61,7 +56,6 @@ getTableSalt(std::string anonTableName) {
std::string std::string
getTableOfSalt(std::string salt_name) { getTableOfSalt(std::string salt_name) {
return salt_name.substr(BASE_SALT_NAME.length() + 3, salt_name.length() - 3 - BASE_SALT_NAME.length()); return salt_name.substr(BASE_SALT_NAME.length() + 3, salt_name.length() - 3 - BASE_SALT_NAME.length());
} }
...@@ -69,8 +63,7 @@ getTableOfSalt(std::string salt_name) { ...@@ -69,8 +63,7 @@ getTableOfSalt(std::string salt_name) {
std::string std::string
getFieldsItSelect(std::list<std::string> & words, getFieldsItSelect(std::list<std::string> & words,
std::list<std::string>::iterator & it) std::list<std::string>::iterator & it) {
{
it = words.begin(); it = words.begin();
it++; it++;
std::string res = "SELECT "; std::string res = "SELECT ";
...@@ -80,7 +73,6 @@ getFieldsItSelect(std::list<std::string> & words, ...@@ -80,7 +73,6 @@ getFieldsItSelect(std::list<std::string> & words,
it++; it++;
res += "DISTINCT "; res += "DISTINCT ";
} }
return res; return res;
} }
...@@ -9,26 +9,20 @@ ...@@ -9,26 +9,20 @@
// can update in place. // can update in place.
// ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; // ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
class AddColumnSubHandler : public AlterSubHandler { class AddColumnSubHandler : public AlterSubHandler {
virtual LEX * virtual LEX *
rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &preamble) rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &preamble)
const const {
{
TableMeta &tm = a.getTableMeta(preamble.dbname, preamble.table); TableMeta &tm = a.getTableMeta(preamble.dbname, preamble.table);
/*collect the keys (and their types) as they may affect the onion layout we use */
// collect the keys (and their types) as they may affect the onion
// layout we use
const auto &key_data = collectKeyData(*lex); const auto &key_data = collectKeyData(*lex);
// Create *Meta objects. // Create *Meta objects.
auto add_it = auto add_it =
List_iterator<Create_field>(lex->alter_info.create_list); List_iterator<Create_field>(lex->alter_info.create_list);
lex->alter_info.create_list = lex->alter_info.create_list =
accumList<Create_field>(add_it, accumList<Create_field>(add_it,
[&a, &tm, &key_data] (List<Create_field> out_list, [&a, &tm, &key_data] (List<Create_field> out_list,
Create_field *cf) Create_field *cf){
{
return createAndRewriteField(a, cf, &tm, false, key_data, return createAndRewriteField(a, cf, &tm, false, key_data,
out_list); out_list);
}); });
...@@ -102,18 +96,17 @@ class DropColumnSubHandler : public AlterSubHandler { ...@@ -102,18 +96,17 @@ class DropColumnSubHandler : public AlterSubHandler {
class ChangeColumnSubHandler : public AlterSubHandler { class ChangeColumnSubHandler : public AlterSubHandler {
virtual LEX * virtual LEX *
rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &preamble) rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &preamble)
const const{
{
FAIL_TextMessageError("implement ChangeColumnSubHandler"); FAIL_TextMessageError("implement ChangeColumnSubHandler");
} }
}; };
/*added should update inplace*/
LEX * ForeignKeySubHandler::rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &preamble) LEX * ForeignKeySubHandler::rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &preamble)
const{ const{
// LEX *const new_lex = copyWithTHD(lex);
TableMeta const &ctm = TableMeta const &ctm =
a.getTableMeta(preamble.dbname, preamble.table); a.getTableMeta(preamble.dbname, preamble.table);
//find essential information from froeign key //find essential information from froeign key
auto it = auto it =
List_iterator<Key>(lex->alter_info.key_list); List_iterator<Key>(lex->alter_info.key_list);
......
...@@ -892,13 +892,12 @@ main() { ...@@ -892,13 +892,12 @@ main() {
continue; continue;
} }
/*
if(curQuery=="back"){ if(curQuery=="back"){
startBack(); startBack();
}else{ }else{
std::cout<<GREEN_BEGIN<<"curQuery: "<<curQuery<<"\n"<<COLOR_END<<std::endl; std::cout<<GREEN_BEGIN<<"curQuery: "<<curQuery<<"\n"<<COLOR_END<<std::endl;
batchTogether(client,curQuery,_thread_id); batchTogether(client,curQuery,_thread_id);
}*/ }
std::unique_ptr<SchemaInfo> schema = myLoadSchemaInfo(); std::unique_ptr<SchemaInfo> schema = myLoadSchemaInfo();
processSchemaInfo(*schema); processSchemaInfo(*schema);
......
...@@ -425,7 +425,6 @@ nextImpl(const ResType &res, const NextParams &nparams) ...@@ -425,7 +425,6 @@ nextImpl(const ResType &res, const NextParams &nparams)
TEST_ErrPkt(deltaOutputAfterQuery(nparams.ps.getEConn(), this->deltas, TEST_ErrPkt(deltaOutputAfterQuery(nparams.ps.getEConn(), this->deltas,
this->embedded_completion_id.get()), this->embedded_completion_id.get()),
"deltaOuputAfterQuery failed for DDL"); "deltaOuputAfterQuery failed for DDL");
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
yield return CR_RESULTS(this->ddl_res.get()); yield return CR_RESULTS(this->ddl_res.get());
} }
......
This diff is collapsed.
...@@ -22,13 +22,12 @@ ...@@ -22,13 +22,12 @@
#include <util/enum_text.hh> #include <util/enum_text.hh>
#include <parser/lex_util.hh> #include <parser/lex_util.hh>
// class/object names we don't care to know the name of /* class/object names we don't care to know the name of */
#define ANON ANON_NAME(__anon_id_const) #define ANON ANON_NAME(__anon_id_const)
// encrypts a constant item based on the information in a // encrypts a constant item based on the information in Analysis
static Item * static Item *
encrypt_item(const Item &i, const OLK &olk, Analysis &a) encrypt_item(const Item &i, const OLK &olk, Analysis &a) {
{
assert(!RiboldMYSQL::is_null(i)); assert(!RiboldMYSQL::is_null(i));
FieldMeta * const fm = olk.key; FieldMeta * const fm = olk.key;
......
...@@ -22,10 +22,9 @@ ...@@ -22,10 +22,9 @@
#include <parser/lex_util.hh> #include <parser/lex_util.hh>
// gives names to classes and objects we don't care to know the name of /*gives names to classes and objects we don't care to know the name of */
#define ANON ANON_NAME(__anon_id_f_) #define ANON ANON_NAME(__anon_id_f_)
CItemTypesDir itemTypes = CItemTypesDir(); CItemTypesDir itemTypes = CItemTypesDir();
CItemFuncDir funcTypes = CItemFuncDir(); CItemFuncDir funcTypes = CItemFuncDir();
CItemFuncNameDir funcNames = CItemFuncNameDir(); CItemFuncNameDir funcNames = CItemFuncNameDir();
...@@ -40,8 +39,7 @@ CItemSumFuncDir sumFuncTypes = CItemSumFuncDir(); ...@@ -40,8 +39,7 @@ CItemSumFuncDir sumFuncTypes = CItemSumFuncDir();
static std::string static std::string
deductPlainTableName(const std::string &field_name, deductPlainTableName(const std::string &field_name,
Name_resolution_context *const context, Name_resolution_context *const context,
Analysis &a) Analysis &a) {
{
assert(context); assert(context);
const TABLE_LIST *current_table = const TABLE_LIST *current_table =
......
...@@ -590,8 +590,6 @@ lowLevelGetCurrentStaleness(const std::unique_ptr<Connect> &e_conn, ...@@ -590,8 +590,6 @@ lowLevelGetCurrentStaleness(const std::unique_ptr<Connect> &e_conn,
const std::string &query = const std::string &query =
" SELECT stale FROM " + MetaData::Table::staleness() + " SELECT stale FROM " + MetaData::Table::staleness() +
" WHERE cache_id = " + std::to_string(cache_id) + ";"; " WHERE cache_id = " + std::to_string(cache_id) + ";";
std::cout<<"query: "<<query<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<std::endl;
std::unique_ptr<DBResult> db_res; std::unique_ptr<DBResult> db_res;
RFIF(e_conn->execute(query, &db_res)); RFIF(e_conn->execute(query, &db_res));
assert(1 == mysql_num_rows(db_res->n)); assert(1 == mysql_num_rows(db_res->n));
......
...@@ -3,15 +3,8 @@ OBJDIRS += parser ...@@ -3,15 +3,8 @@ OBJDIRS += parser
PARSERSRC := sql_utils.cc lex_util.cc embedmysql.cc \ PARSERSRC := sql_utils.cc lex_util.cc embedmysql.cc \
mysqld-filler.cc mysql_type_metadata.cc mysqld-filler.cc mysql_type_metadata.cc
##PARSERPROGS := print-back
##PARSERPROGOBJS := $(pathsubst %, $(OBJDIR)/parser/%,$(PARSERPROGS))
all: $(OBJDIR)/libedbparser.so all: $(OBJDIR)/libedbparser.so
##$(PARSERPROGOBJS): %: %.o $(OBJDIR)/libedbparser.so $(OBJDIR)/libedbutil.so
## $(CXX) $< -o $@ -ledbparser $(LDFLAGS) $(LDRPATH) -ledbutil -lcryptdb
EDBPARSER_OBJS := $(patsubst %.cc,$(OBJDIR)/parser/%.o,$(PARSERSRC)) EDBPARSER_OBJS := $(patsubst %.cc,$(OBJDIR)/parser/%.o,$(PARSERSRC))
$(OBJDIR)/libedbparser.so: $(EDBPARSER_OBJS) \ $(OBJDIR)/libedbparser.so: $(EDBPARSER_OBJS) \
...@@ -21,5 +14,4 @@ $(OBJDIR)/libedbparser.so: $(EDBPARSER_OBJS) \ ...@@ -21,5 +14,4 @@ $(OBJDIR)/libedbparser.so: $(EDBPARSER_OBJS) \
-ledbutil -ledbcrypto \ -ledbutil -ledbcrypto \
-Wl,--whole-archive -L$(MYBUILD)/libmysqld -lmysqld \ -Wl,--whole-archive -L$(MYBUILD)/libmysqld -lmysqld \
-Wl,--no-whole-archive -laio -lz -ldl -lrt -lcrypt -Wl,--no-whole-archive -laio -lz -ldl -lrt -lcrypt
# vim: set noexpandtab: # vim: set noexpandtab:
...@@ -23,24 +23,18 @@ using namespace std; ...@@ -23,24 +23,18 @@ using namespace std;
extern "C" void *create_embedded_thd(int client_flag); extern "C" void *create_embedded_thd(int client_flag);
void void
query_parse::cleanup() query_parse::cleanup(){
{
// if (annot) {
// delete annot;
// }
if (t) { if (t) {
t->end_statement(); t->end_statement();
t->cleanup_after_query(); t->cleanup_after_query();
close_thread_tables(t); close_thread_tables(t);
--thread_count; --thread_count;
// t->clear_data_list();
delete t; delete t;
t = 0; t = 0;
} }
} }
query_parse::~query_parse() query_parse::~query_parse() {
{
cleanup(); cleanup();
} }
...@@ -49,16 +43,6 @@ query_parse::lex() ...@@ -49,16 +43,6 @@ query_parse::lex()
{ {
return t->lex; return t->lex;
} }
/*
static void
cloneItemInOrder(ORDER * o) {
assert_s((*o->item)->type() == Item::Type::FIELD_ITEM, " support for order by/group by non-field not currently implemented" );
Item ** tmp = (Item **)malloc(sizeof(Item *));
*tmp = new Item_field(current_thd, static_cast<Item_field *>(*o->item));
assert_s(*tmp, "clone item failed on order by element, elements perhaps non constant which is not currently implemented");
o->item = tmp;
}
*/
/* /*
* For the whys and hows; * For the whys and hows;
...@@ -104,10 +88,7 @@ query_parse::query_parse(const std::string &db, const std::string &q) ...@@ -104,10 +88,7 @@ query_parse::query_parse(const std::string &db, const std::string &q)
if (strncmp(toLowerCase(q).c_str(), "cryptdb", 7) == 0) { if (strncmp(toLowerCase(q).c_str(), "cryptdb", 7) == 0) {
//do not use Annotation now //do not use Annotation now
// annot = new Annotation(q);
return; return;
} else {
//annot = NULL;
} }
try { try {
//set db //set db
......
...@@ -3,12 +3,8 @@ ...@@ -3,12 +3,8 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
//#include <parser/Annotation.hh>
#include <util/util.hh> #include <util/util.hh>
#include <util/onions.hh> #include <util/onions.hh>
#include <mysql.h> #include <mysql.h>
#include <sql_base.h> #include <sql_base.h>
...@@ -17,12 +13,9 @@ class query_parse { ...@@ -17,12 +13,9 @@ class query_parse {
query_parse(const std::string &db, const std::string &q); query_parse(const std::string &db, const std::string &q);
virtual ~query_parse(); virtual ~query_parse();
LEX *lex(); LEX *lex();
// Annotation *annot;
private: private:
void cleanup(); void cleanup();
THD *t; THD *t;
//这里包含了词法分析和语法分析时候, 使用的内部状态. Parser_state ps; /*这里包含了词法分析和语法分析时候, 使用的内部状态*/
Parser_state ps;
}; };
...@@ -261,7 +261,6 @@ RiboldMYSQL::get_select_lex(const Item_subselect &i) ...@@ -261,7 +261,6 @@ RiboldMYSQL::get_select_lex(const Item_subselect &i)
return const_cast<Item_subselect &>(i).get_select_lex(); return const_cast<Item_subselect &>(i).get_select_lex();
} }
// Item::val_str(...) modifies/returns an internal buffer sometimes.
std::string RiboldMYSQL::val_str(const Item &i, bool *is_null) std::string RiboldMYSQL::val_str(const Item &i, bool *is_null)
{ {
static const std::string empty_string = ""; static const std::string empty_string = "";
......
...@@ -134,11 +134,10 @@ mapList(List_iterator<InType> it, std::function<OutType *(InType *)> op) ...@@ -134,11 +134,10 @@ mapList(List_iterator<InType> it, std::function<OutType *(InType *)> op)
return newList; return newList;
} }
//注意这里的function返回值是List<Type>, 参数是List<Type>以及Type* /* 注意这里的function返回值是List<Type>, 参数是List<Type>以及Type* */
template <typename Type> List<Type> template <typename Type> List<Type>
accumList(List_iterator<Type> it, accumList(List_iterator<Type> it,
std::function<List<Type>(List<Type>, Type *)> op) std::function<List<Type>(List<Type>, Type *)> op) {
{
List<Type> accum; List<Type> accum;
for (Type *element = it++; element ; element = it++) { for (Type *element = it++; element ; element = it++) {
...@@ -149,8 +148,7 @@ accumList(List_iterator<Type> it, ...@@ -149,8 +148,7 @@ accumList(List_iterator<Type> it,
} }
template <typename T> List<T> * template <typename T> List<T> *
vectorToListWithTHD(std::vector<T *> v) vectorToListWithTHD(std::vector<T *> v) {
{
List<T> *const lst = new (current_thd->mem_root) List<T>; List<T> *const lst = new (current_thd->mem_root) List<T>;
for (auto it : v) { for (auto it : v) {
lst->push_back(it); lst->push_back(it);
...@@ -160,8 +158,7 @@ vectorToListWithTHD(std::vector<T *> v) ...@@ -160,8 +158,7 @@ vectorToListWithTHD(std::vector<T *> v)
} }
template <typename Type> List<Type> template <typename Type> List<Type>
filterList(List_iterator<Type> it, std::function<bool(Type *)> op) filterList(List_iterator<Type> it, std::function<bool(Type *)> op) {
{
List<Type> new_list; List<Type> new_list;
for (Type *element = it++; element ; element = it++) { for (Type *element = it++; element ; element = it++) {
......
...@@ -12,8 +12,7 @@ using namespace std; ...@@ -12,8 +12,7 @@ using namespace std;
static bool lib_initialized = false; static bool lib_initialized = false;
void void
init_mysql(const string &embed_db) init_mysql(const string &embed_db){
{
// FIXME: can still get a weird case where something calls // FIXME: can still get a weird case where something calls
// init_mysql(...) and lib_initialized is true so it continues on to // init_mysql(...) and lib_initialized is true so it continues on to
// execute a query against the embedded database; but the thread // execute a query against the embedded database; but the thread
...@@ -41,8 +40,7 @@ init_mysql(const string &embed_db) ...@@ -41,8 +40,7 @@ init_mysql(const string &embed_db)
} }
char * char *
make_thd_string(const string &s, size_t *lenp) make_thd_string(const string &s, size_t *lenp){
{
THD *thd = current_thd; THD *thd = current_thd;
assert(thd); assert(thd);
if (lenp) if (lenp)
...@@ -64,8 +62,7 @@ ItemToString(const Item &i) { ...@@ -64,8 +62,7 @@ ItemToString(const Item &i) {
} }
std::string std::string
printItemToString(const Item &i) printItemToString(const Item &i){
{
std::ostringstream o; std::ostringstream o;
o << i; o << i;
return o.str(); return o.str();
......
...@@ -562,27 +562,6 @@ enableOrDisableKeysOutput(const LEX &lex) ...@@ -562,27 +562,6 @@ enableOrDisableKeysOutput(const LEX &lex)
return out; return out;
} }
/*
static std::string
prettyLockType(enum thr_lock_type lock_type)
{
switch (lock_type) {
case TL_READ:
case TL_READ_NO_INSERT:
return "READ";
case TL_WRITE:
case TL_WRITE_DEFAULT:
return "WRITE";
default:
// FIXME: Use TEST_TextMessageError
std::cerr << "Unsupported lock type: " << lock_type
<< std::endl;
assert(false);
}
}
*/
//process normal key in alter table command, do not process foreign key //process normal key in alter table command, do not process foreign key
static std::string process_normal_key(LEX &lex){ static std::string process_normal_key(LEX &lex){
std::ostringstream key_output; std::ostringstream key_output;
......
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