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());
} }
......
...@@ -66,7 +66,6 @@ void rewriteInsertHelper(const Item &i, const FieldMeta &fm, Analysis &a, ...@@ -66,7 +66,6 @@ void rewriteInsertHelper(const Item &i, const FieldMeta &fm, Analysis &a,
class InsertHandler : public DMLHandler { class InsertHandler : public DMLHandler {
virtual void gather(Analysis &a, LEX *const lex) const virtual void gather(Analysis &a, LEX *const lex) const
{ {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
//only select xxx etc?不是的!!! //only select xxx etc?不是的!!!
process_select_lex(lex->select_lex, a); process_select_lex(lex->select_lex, a);
...@@ -232,9 +231,7 @@ class InsertHandler : public DMLHandler { ...@@ -232,9 +231,7 @@ class InsertHandler : public DMLHandler {
}; };
class UpdateHandler : public DMLHandler { class UpdateHandler : public DMLHandler {
virtual void gather(Analysis &a, LEX *lex) const virtual void gather(Analysis &a, LEX *lex) const {
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
process_table_list(lex->select_lex.top_join_list, a); process_table_list(lex->select_lex.top_join_list, a);
if (lex->select_lex.item_list.head()) { if (lex->select_lex.item_list.head()) {
...@@ -300,9 +297,7 @@ class UpdateHandler : public DMLHandler { ...@@ -300,9 +297,7 @@ class UpdateHandler : public DMLHandler {
class DeleteHandler : public DMLHandler { class DeleteHandler : public DMLHandler {
virtual void gather(Analysis &a, LEX *const lex) virtual void gather(Analysis &a, LEX *const lex)
const const {
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
process_select_lex(lex->select_lex, a); process_select_lex(lex->select_lex, a);
} }
...@@ -322,16 +317,13 @@ class DeleteHandler : public DMLHandler { ...@@ -322,16 +317,13 @@ class DeleteHandler : public DMLHandler {
class MultiDeleteHandler : public DMLHandler { class MultiDeleteHandler : public DMLHandler {
virtual void gather(Analysis &a, LEX *const lex) virtual void gather(Analysis &a, LEX *const lex)
const const {
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
process_select_lex(lex->select_lex, a); process_select_lex(lex->select_lex, a);
} }
virtual AbstractQueryExecutor * virtual AbstractQueryExecutor *
rewrite(Analysis &a, LEX *lex) rewrite(Analysis &a, LEX *lex)
const const {
{
LEX *const new_lex = copyWithTHD(lex); LEX *const new_lex = copyWithTHD(lex);
// the multidelete looks like this // the multidelete looks like this
// $ DELETE <LEX::auxiliary_...> FROM <LEX::query_tables>; // $ DELETE <LEX::auxiliary_...> FROM <LEX::query_tables>;
...@@ -444,9 +436,7 @@ class SelectHandler : public DMLHandler { ...@@ -444,9 +436,7 @@ class SelectHandler : public DMLHandler {
}; };
AbstractQueryExecutor *DMLHandler:: AbstractQueryExecutor *DMLHandler::
transformLex(Analysis &analysis, LEX *lex) const transformLex(Analysis &analysis, LEX *lex) const {
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
this->gather(analysis, lex); this->gather(analysis, lex);
return this->rewrite(analysis, lex); return this->rewrite(analysis, lex);
} }
...@@ -540,7 +530,6 @@ gatherAndAddAnalysisRewritePlanForFieldValuePair(const Item_field &field, ...@@ -540,7 +530,6 @@ gatherAndAddAnalysisRewritePlanForFieldValuePair(const Item_field &field,
const Item &val, const Item &val,
Analysis &a) Analysis &a)
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
a.rewritePlans[&val] = std::unique_ptr<RewritePlan>(gather(val, a)); a.rewritePlans[&val] = std::unique_ptr<RewritePlan>(gather(val, a));
a.rewritePlans[&field] = a.rewritePlans[&field] =
std::unique_ptr<RewritePlan>(gather(field, a)); std::unique_ptr<RewritePlan>(gather(field, a));
...@@ -555,7 +544,6 @@ static SQL_I_List<ORDER> * ...@@ -555,7 +544,6 @@ static SQL_I_List<ORDER> *
rewrite_order(Analysis &a, const SQL_I_List<ORDER> &lst, rewrite_order(Analysis &a, const SQL_I_List<ORDER> &lst,
const EncSet &constr, const std::string &name) const EncSet &constr, const std::string &name)
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<name<<std::endl<<std::endl;
SQL_I_List<ORDER> *const new_lst = copyWithTHD(&lst); SQL_I_List<ORDER> *const new_lst = copyWithTHD(&lst);
ORDER * prev = NULL; ORDER * prev = NULL;
for (ORDER *o = lst.first; o; o = o->next) { for (ORDER *o = lst.first; o; o = o->next) {
...@@ -576,7 +564,6 @@ rewrite_order(Analysis &a, const SQL_I_List<ORDER> &lst, ...@@ -576,7 +564,6 @@ rewrite_order(Analysis &a, const SQL_I_List<ORDER> &lst,
static st_select_lex * static st_select_lex *
rewrite_filters_lex(const st_select_lex &select_lex, Analysis & a) rewrite_filters_lex(const st_select_lex &select_lex, Analysis & a)
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
st_select_lex *const new_select_lex = copyWithTHD(&select_lex); st_select_lex *const new_select_lex = copyWithTHD(&select_lex);
// FIXME: Use const reference for list. // FIXME: Use const reference for list.
...@@ -604,7 +591,6 @@ rewrite_field_value_pairs(List_iterator<Item> fd_it, ...@@ -604,7 +591,6 @@ rewrite_field_value_pairs(List_iterator<Item> fd_it,
List_iterator<Item> val_it, Analysis &a, List_iterator<Item> val_it, Analysis &a,
List<Item> *const res_fields, List<Item> *const res_fields,
List<Item> *const res_values) { List<Item> *const res_values) {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
for (;;) { for (;;) {
const Item *const field_item = fd_it++; const Item *const field_item = fd_it++;
const Item *const value_item = val_it++; const Item *const value_item = val_it++;
...@@ -646,7 +632,6 @@ rewrite_field_value_pairs(List_iterator<Item> fd_it, ...@@ -646,7 +632,6 @@ rewrite_field_value_pairs(List_iterator<Item> fd_it,
static void static void
addToReturn(ReturnMeta *const rm, int pos, const OLK &constr, addToReturn(ReturnMeta *const rm, int pos, const OLK &constr,
bool has_salt, const std::string &name){ bool has_salt, const std::string &name){
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const bool test = static_cast<unsigned int>(pos) == rm->rfmeta.size(); const bool test = static_cast<unsigned int>(pos) == rm->rfmeta.size();
TEST_TextMessageError(test, "ReturnMeta has badly ordered" TEST_TextMessageError(test, "ReturnMeta has badly ordered"
" ReturnFields!"); " ReturnFields!");
...@@ -660,7 +645,6 @@ addToReturn(ReturnMeta *const rm, int pos, const OLK &constr, ...@@ -660,7 +645,6 @@ addToReturn(ReturnMeta *const rm, int pos, const OLK &constr,
static void static void
addSaltToReturn(ReturnMeta *const rm, int pos) addSaltToReturn(ReturnMeta *const rm, int pos)
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const bool test = static_cast<unsigned int>(pos) == rm->rfmeta.size(); const bool test = static_cast<unsigned int>(pos) == rm->rfmeta.size();
TEST_TextMessageError(test, "ReturnMeta has badly ordered" TEST_TextMessageError(test, "ReturnMeta has badly ordered"
" ReturnFields!"); " ReturnFields!");
...@@ -674,7 +658,6 @@ addSaltToReturn(ReturnMeta *const rm, int pos) ...@@ -674,7 +658,6 @@ addSaltToReturn(ReturnMeta *const rm, int pos)
static void static void
rewrite_proj(const Item &i, const RewritePlan &rp, Analysis &a, rewrite_proj(const Item &i, const RewritePlan &rp, Analysis &a,
List<Item> *const newList) { List<Item> *const newList) {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
AssignOnce<OLK> olk; AssignOnce<OLK> olk;
AssignOnce<Item *> ir; AssignOnce<Item *> ir;
...@@ -724,7 +707,6 @@ rewrite_proj(const Item &i, const RewritePlan &rp, Analysis &a, ...@@ -724,7 +707,6 @@ rewrite_proj(const Item &i, const RewritePlan &rp, Analysis &a,
st_select_lex * st_select_lex *
rewrite_select_lex(const st_select_lex &select_lex, Analysis &a) rewrite_select_lex(const st_select_lex &select_lex, Analysis &a)
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
// rewrite_filters_lex must be called before rewrite_proj because // rewrite_filters_lex must be called before rewrite_proj because
// it is responsible for filling Analysis::item_cache which // it is responsible for filling Analysis::item_cache which
// rewrite_proj uses. // rewrite_proj uses.
...@@ -769,7 +751,6 @@ rewrite_select_lex(const st_select_lex &select_lex, Analysis &a) ...@@ -769,7 +751,6 @@ rewrite_select_lex(const st_select_lex &select_lex, Analysis &a)
static void static void
process_table_aliases(const List<TABLE_LIST> &tll, Analysis &a) process_table_aliases(const List<TABLE_LIST> &tll, Analysis &a)
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
RiboldMYSQL::constList_iterator<TABLE_LIST> join_it(tll); RiboldMYSQL::constList_iterator<TABLE_LIST> join_it(tll);
for (;;) { for (;;) {
const TABLE_LIST *const t = join_it++; const TABLE_LIST *const t = join_it++;
...@@ -795,7 +776,6 @@ static void ...@@ -795,7 +776,6 @@ static void
process_table_joins_and_derived(const List<TABLE_LIST> &tll, process_table_joins_and_derived(const List<TABLE_LIST> &tll,
Analysis &a) Analysis &a)
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
RiboldMYSQL::constList_iterator<TABLE_LIST> join_it(tll); RiboldMYSQL::constList_iterator<TABLE_LIST> join_it(tll);
for (;;) { for (;;) {
const TABLE_LIST *const t = join_it++; const TABLE_LIST *const t = join_it++;
...@@ -831,7 +811,6 @@ process_table_joins_and_derived(const List<TABLE_LIST> &tll, ...@@ -831,7 +811,6 @@ process_table_joins_and_derived(const List<TABLE_LIST> &tll,
void void
process_table_list(const List<TABLE_LIST> &tll, Analysis & a) process_table_list(const List<TABLE_LIST> &tll, Analysis & a)
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
/* /*
* later, need to rewrite different joins, e.g. * later, need to rewrite different joins, e.g.
* SELECT g2_ChildEntity.g_id, IF(ai0.g_id IS NULL, 1, 0) AS albumsFirst, g2_Item.g_originationTimestamp FROM g2_ChildEntity LEFT JOIN g2_AlbumItem AS ai0 ON g2_ChildEntity.g_id = ai0.g_id INNER JOIN g2_Item ON g2_ChildEntity.g_id = g2_Item.g_id INNER JOIN g2_AccessSubscriberMap ON g2_ChildEntity.g_id = g2_AccessSubscriberMap.g_itemId ... * SELECT g2_ChildEntity.g_id, IF(ai0.g_id IS NULL, 1, 0) AS albumsFirst, g2_Item.g_originationTimestamp FROM g2_ChildEntity LEFT JOIN g2_AlbumItem AS ai0 ON g2_ChildEntity.g_id = ai0.g_id INNER JOIN g2_Item ON g2_ChildEntity.g_id = g2_Item.g_id INNER JOIN g2_AccessSubscriberMap ON g2_ChildEntity.g_id = g2_AccessSubscriberMap.g_itemId ...
...@@ -843,7 +822,6 @@ process_table_list(const List<TABLE_LIST> &tll, Analysis & a) ...@@ -843,7 +822,6 @@ process_table_list(const List<TABLE_LIST> &tll, Analysis & a)
static bool static bool
invalidates(const FieldMeta &fm, const EncSet & es){ invalidates(const FieldMeta &fm, const EncSet & es){
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
for (const auto &om_it : fm.getChildren()) { for (const auto &om_it : fm.getChildren()) {
onion const o = om_it.first.getValue(); onion const o = om_it.first.getValue();
if (es.osl.find(o) == es.osl.end()) { if (es.osl.find(o) == es.osl.end()) {
...@@ -858,7 +836,6 @@ SIMPLE_UPDATE_TYPE ...@@ -858,7 +836,6 @@ SIMPLE_UPDATE_TYPE
determineUpdateType(const Item &value_item, const FieldMeta &fm, determineUpdateType(const Item &value_item, const FieldMeta &fm,
const EncSet &es) const EncSet &es)
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
if (invalidates(fm, es)) { if (invalidates(fm, es)) {
return SIMPLE_UPDATE_TYPE::UNSUPPORTED; return SIMPLE_UPDATE_TYPE::UNSUPPORTED;
} }
...@@ -883,7 +860,6 @@ doPairRewrite(FieldMeta &fm, const EncSet &es, ...@@ -883,7 +860,6 @@ doPairRewrite(FieldMeta &fm, const EncSet &es,
List<Item> *const res_fields, List<Item> *const res_values, List<Item> *const res_fields, List<Item> *const res_values,
Analysis &a) Analysis &a)
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const std::unique_ptr<RewritePlan> &field_rp = const std::unique_ptr<RewritePlan> &field_rp =
constGetAssert(a.rewritePlans, constGetAssert(a.rewritePlans,
&static_cast<const Item &>(field_item)); &static_cast<const Item &>(field_item));
...@@ -909,7 +885,6 @@ addSalt(FieldMeta &fm, const Item_field &field_item, ...@@ -909,7 +885,6 @@ addSalt(FieldMeta &fm, const Item_field &field_item,
Analysis &a, Analysis &a,
std::function<Item *(const Item_field &rew_fd)> getSaltValue) std::function<Item *(const Item_field &rew_fd)> getSaltValue)
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
assert(res_fields->elements != 0); assert(res_fields->elements != 0);
const Item_field * const rew_fd = const Item_field * const rew_fd =
static_cast<Item_field *>(res_fields->head()); static_cast<Item_field *>(res_fields->head());
...@@ -929,11 +904,9 @@ handleUpdateType(SIMPLE_UPDATE_TYPE update_type, const EncSet &es, ...@@ -929,11 +904,9 @@ handleUpdateType(SIMPLE_UPDATE_TYPE update_type, const EncSet &es,
List<Item> *const res_fields, List<Item> *const res_fields,
List<Item> *const res_values, Analysis &a) List<Item> *const res_values, Analysis &a)
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
FieldMeta &fm = FieldMeta &fm =
a.getFieldMeta(a.getDatabaseName(), field_item.table_name, a.getFieldMeta(a.getDatabaseName(), field_item.table_name,
field_item.field_name); field_item.field_name);
switch (update_type) { switch (update_type) {
case SIMPLE_UPDATE_TYPE::NEW_VALUE: { case SIMPLE_UPDATE_TYPE::NEW_VALUE: {
bool add_salt = false; bool add_salt = false;
...@@ -1001,13 +974,10 @@ handleUpdateType(SIMPLE_UPDATE_TYPE update_type, const EncSet &es, ...@@ -1001,13 +974,10 @@ handleUpdateType(SIMPLE_UPDATE_TYPE update_type, const EncSet &es,
class SetHandler : public DMLHandler { class SetHandler : public DMLHandler {
virtual void gather(Analysis &a, LEX *const lex) const virtual void gather(Analysis &a, LEX *const lex) const
{ {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
// no-op
} }
virtual AbstractQueryExecutor *rewrite(Analysis &a, LEX *lex) const virtual AbstractQueryExecutor *rewrite(Analysis &a, LEX *lex) const
{ {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
#define DIRECTIVE_HANDLER(function) \ #define DIRECTIVE_HANDLER(function) \
std::bind((function), this, std::placeholders::_1, \ std::bind((function), this, std::placeholders::_1, \
std::placeholders::_2) std::placeholders::_2)
...@@ -1036,7 +1006,6 @@ class SetHandler : public DMLHandler { ...@@ -1036,7 +1006,6 @@ class SetHandler : public DMLHandler {
switch (v->varType()) { switch (v->varType()) {
case set_var_base::V_USER: { case set_var_base::V_USER: {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const set_var_user *const user_v = const set_var_user *const user_v =
static_cast<const set_var_user *>(v); static_cast<const set_var_user *>(v);
Item_func_set_user_var *const i = Item_func_set_user_var *const i =
...@@ -1079,7 +1048,6 @@ class SetHandler : public DMLHandler { ...@@ -1079,7 +1048,6 @@ class SetHandler : public DMLHandler {
var_pairs[var_name] = var_value; var_pairs[var_name] = var_value;
} }
case set_var_base::V_SYSTEM: { case set_var_base::V_SYSTEM: {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
// do not allow the client to put us into SQL_SAFE_UPDATES // do not allow the client to put us into SQL_SAFE_UPDATES
// mode; else bad things will happen // mode; else bad things will happen
const set_var *const set_v = const set_var *const set_v =
...@@ -1096,7 +1064,6 @@ class SetHandler : public DMLHandler { ...@@ -1096,7 +1064,6 @@ class SetHandler : public DMLHandler {
} }
case set_var_base::V_PASSWORD: case set_var_base::V_PASSWORD:
case set_var_base::V_COLLATION: case set_var_base::V_COLLATION:
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
break; break;
default: default:
assert(false); assert(false);
...@@ -1117,7 +1084,6 @@ private: ...@@ -1117,7 +1084,6 @@ private:
handleAdjustDirective(std::map<std::string, std::string> &var_pairs, handleAdjustDirective(std::map<std::string, std::string> &var_pairs,
Analysis &a) const Analysis &a) const
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const ParameterCollection &params = collectParameters(var_pairs, a); const ParameterCollection &params = collectParameters(var_pairs, a);
for (const auto &it : params.onions) { for (const auto &it : params.onions) {
...@@ -1140,7 +1106,6 @@ private: ...@@ -1140,7 +1106,6 @@ private:
handleShowDirective(std::map<std::string, std::string> &var_pairs, handleShowDirective(std::map<std::string, std::string> &var_pairs,
Analysis &a) const Analysis &a) const
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
return new ShowDirectiveExecutor(a.getSchema()); return new ShowDirectiveExecutor(a.getSchema());
} }
...@@ -1148,7 +1113,6 @@ private: ...@@ -1148,7 +1113,6 @@ private:
handleSensitiveDirective(std::map<std::string, std::string> &var_pairs, handleSensitiveDirective(std::map<std::string, std::string> &var_pairs,
Analysis &a) const Analysis &a) const
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
assert(a.deltas.size() == 0); assert(a.deltas.size() == 0);
const ParameterCollection &params = collectParameters(var_pairs, a); const ParameterCollection &params = collectParameters(var_pairs, a);
...@@ -1173,7 +1137,6 @@ private: ...@@ -1173,7 +1137,6 @@ private:
handleKillZoneDirective(std::map<std::string, std::string> &var_pairs, handleKillZoneDirective(std::map<std::string, std::string> &var_pairs,
Analysis &a) const Analysis &a) const
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
auto count = var_pairs.find(std::string("count")); auto count = var_pairs.find(std::string("count"));
auto where = var_pairs.find(std::string("where")); auto where = var_pairs.find(std::string("where"));
TEST_Text(var_pairs.end() != count TEST_Text(var_pairs.end() != count
...@@ -1385,7 +1348,6 @@ nextImpl(const ResType &res, const NextParams &nparams) ...@@ -1385,7 +1348,6 @@ nextImpl(const ResType &res, const NextParams &nparams)
static std::pair<std::string, ReturnMeta> static std::pair<std::string, ReturnMeta>
rewriteAndGetFirstQuery(const std::string &query, NextParams nparams) rewriteAndGetFirstQuery(const std::string &query, NextParams nparams)
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
try { try {
const std::shared_ptr<const SchemaInfo> schema = const std::shared_ptr<const SchemaInfo> schema =
nparams.ps.getSchemaInfo(); nparams.ps.getSchemaInfo();
...@@ -1423,7 +1385,6 @@ nextImpl(const ResType &res, const NextParams &nparams) ...@@ -1423,7 +1385,6 @@ nextImpl(const ResType &res, const NextParams &nparams)
crYield(std::make_pair(true, cond_trx)); crYield(std::make_pair(true, cond_trx));
crEndBlock crEndBlock
*/ */
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
reenter(this->corot) { reenter(this->corot) {
assert(res.success()); assert(res.success());
...@@ -1606,7 +1567,6 @@ std::pair<AbstractQueryExecutor::ResultType, AbstractAnything *> ...@@ -1606,7 +1567,6 @@ std::pair<AbstractQueryExecutor::ResultType, AbstractAnything *>
ShowDirectiveExecutor:: ShowDirectiveExecutor::
nextImpl(const ResType &res, const NextParams &nparams) nextImpl(const ResType &res, const NextParams &nparams)
{ {
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
reenter(this->corot) { reenter(this->corot) {
yield { yield {
TEST_ErrPkt(deleteAllShowDirectiveEntries(nparams.ps.getEConn()), TEST_ErrPkt(deleteAllShowDirectiveEntries(nparams.ps.getEConn()),
...@@ -1662,7 +1622,6 @@ nextImpl(const ResType &res, const NextParams &nparams) ...@@ -1662,7 +1622,6 @@ nextImpl(const ResType &res, const NextParams &nparams)
bool ShowDirectiveExecutor:: bool ShowDirectiveExecutor::
deleteAllShowDirectiveEntries(const std::unique_ptr<Connect> &e_conn) deleteAllShowDirectiveEntries(const std::unique_ptr<Connect> &e_conn)
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const std::string &query = const std::string &query =
"DELETE FROM " + MetaData::Table::showDirective() + ";"; "DELETE FROM " + MetaData::Table::showDirective() + ";";
return e_conn->execute(query); return e_conn->execute(query);
...@@ -1676,7 +1635,6 @@ addShowDirectiveEntry(const std::unique_ptr<Connect> &e_conn, ...@@ -1676,7 +1635,6 @@ addShowDirectiveEntry(const std::unique_ptr<Connect> &e_conn,
const std::string &onion, const std::string &onion,
const std::string &level) const std::string &level)
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const std::string &query = const std::string &query =
"INSERT INTO " + MetaData::Table::showDirective() + "INSERT INTO " + MetaData::Table::showDirective() +
" (_database, _table, _field, _onion, _level) VALUES " " (_database, _table, _field, _onion, _level) VALUES "
...@@ -1691,7 +1649,6 @@ bool ShowDirectiveExecutor:: ...@@ -1691,7 +1649,6 @@ bool ShowDirectiveExecutor::
getAllShowDirectiveEntries(const std::unique_ptr<Connect> &e_conn, getAllShowDirectiveEntries(const std::unique_ptr<Connect> &e_conn,
std::unique_ptr<DBResult> *db_res) std::unique_ptr<DBResult> *db_res)
{ {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
assert(db_res); assert(db_res);
const std::string &query = const std::string &query =
"SELECT * FROM " + MetaData::Table::showDirective() + ";"; "SELECT * FROM " + MetaData::Table::showDirective() + ";";
...@@ -1702,7 +1659,6 @@ std::pair<AbstractQueryExecutor::ResultType, AbstractAnything *> ...@@ -1702,7 +1659,6 @@ std::pair<AbstractQueryExecutor::ResultType, AbstractAnything *>
SensitiveDirectiveExecutor:: SensitiveDirectiveExecutor::
nextImpl(const ResType &res, const NextParams &nparams) nextImpl(const ResType &res, const NextParams &nparams)
{ {
//std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
reenter(this->corot) { reenter(this->corot) {
yield { yield {
TEST_ErrPkt(nparams.ps.getEConn()->execute("START TRANSACTION"), TEST_ErrPkt(nparams.ps.getEConn()->execute("START TRANSACTION"),
...@@ -1762,9 +1718,6 @@ nextImpl(const ResType &res, const NextParams &nparams) ...@@ -1762,9 +1718,6 @@ nextImpl(const ResType &res, const NextParams &nparams)
assert(false); assert(false);
} }
std::pair<AbstractQueryExecutor::ResultType, AbstractAnything *> std::pair<AbstractQueryExecutor::ResultType, AbstractAnything *>
ShowCreateTableExecutor:: ShowCreateTableExecutor::
nextImpl(const ResType &res, const NextParams &nparams){ nextImpl(const ResType &res, const NextParams &nparams){
...@@ -1773,37 +1726,16 @@ nextImpl(const ResType &res, const NextParams &nparams){ ...@@ -1773,37 +1726,16 @@ nextImpl(const ResType &res, const NextParams &nparams){
reenter(this->corot) { reenter(this->corot) {
yield return CR_QUERY_AGAIN(this->query); yield return CR_QUERY_AGAIN(this->query);
TEST_ErrPkt(res.success(), "show create table tables failed"); TEST_ErrPkt(res.success(), "show create table tables failed");
yield { yield {
//how to find schemaInfo?? we can get it directly
const std::shared_ptr<const SchemaInfo> &schema = const std::shared_ptr<const SchemaInfo> &schema =
nparams.ps.getSchemaInfo(); nparams.ps.getSchemaInfo();
const DatabaseMeta *const dm = const DatabaseMeta *const dm =
schema->getChild(IdentityMetaKey(nparams.default_db)); schema->getChild(IdentityMetaKey(nparams.default_db));
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;
//adapted from show tables;
/*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 *>
{make_item_string(plain_table_name.getValue())});
}
}
}*/
return CR_RESULTS(ResType(res, new_rows)); return CR_RESULTS(ResType(res, new_rows));
} }
} }
//avoid reach the end
assert(false); assert(false);
} }
...@@ -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