Commit 9dcd9f88 authored by Casualet's avatar Casualet

tweak format

parent 214227cd
......@@ -295,7 +295,6 @@ dropAll(const std::unique_ptr<Connect> &conn)
std::vector<std::string>
getAllUDFs()
{
//std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
std::vector<std::string> udfs;
for (const udf_func * const u: udf_list) {
std::stringstream ss;
......@@ -311,11 +310,6 @@ getAllUDFs()
udfs.push_back(ss.str());
}
return udfs;
}
......@@ -403,9 +397,8 @@ SharedProxyState::SharedProxyState(ConnectionInfo ci,
assert(loadStoredProcedures(conn));
}
SharedProxyState::~SharedProxyState()
{
// mysql_library_end();
SharedProxyState::~SharedProxyState() {
}
int
......
......@@ -7,7 +7,7 @@ CRYPTDB_SRCS := schema.cc Translator.cc Connect.cc \
rewrite_func.cc rewrite_sum.cc metadata_tables.cc \
error.cc stored_procedures.cc rewrite_ds.cc rewrite_main.cc
CRYPTDB_PROGS:=
CRYPTDB_PROGS:= cdb_test
CRYPTDBPROGOBJS := $(patsubst %,$(OBJDIR)/main/%,$(CRYPTDB_PROGS))
......
......@@ -14,17 +14,14 @@
// TODO: Make length longer.
// TODO: Ensure some level of collision resistance.
std::string
getpRandomName()
{
getpRandomName(){
// FIXME: Not using numbers because.
// 'CREATE TABLE a (2e integer); <---- succeeds
// 'CREATE TABLE b (2e5 integer); <--- fails
static const char valids[] =
// "0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static int out_length = 10;
char output[out_length + 1];
std::function<bool()> wrap_srand =[](){srand(time(NULL)); return true;};
std::function<void(bool)> do_nothing = [] (bool b) {return;};
static bool danger_will_robinson = wrap_srand();
......@@ -34,14 +31,12 @@ getpRandomName()
output[i] = valids[rand() % strlen(valids)];
}
output[out_length] = 0;
return std::string(output);
}
std::string
nextAutoInc(std::map<std::string, unsigned int > & autoInc,
std::string fullname)
{
std::string fullname){
std::string val;
if (autoInc.find(fullname) == autoInc.end()) {
val = "1";
......@@ -61,7 +56,6 @@ getTableSalt(std::string anonTableName) {
std::string
getTableOfSalt(std::string salt_name) {
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) {
std::string
getFieldsItSelect(std::list<std::string> & words,
std::list<std::string>::iterator & it)
{
std::list<std::string>::iterator & it) {
it = words.begin();
it++;
std::string res = "SELECT ";
......@@ -80,7 +73,6 @@ getFieldsItSelect(std::list<std::string> & words,
it++;
res += "DISTINCT ";
}
return res;
}
......@@ -9,26 +9,20 @@
// can update in place.
// ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
class AddColumnSubHandler : public AlterSubHandler {
virtual LEX *
rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &preamble)
const
{
const {
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);
// Create *Meta objects.
auto add_it =
List_iterator<Create_field>(lex->alter_info.create_list);
lex->alter_info.create_list =
accumList<Create_field>(add_it,
[&a, &tm, &key_data] (List<Create_field> out_list,
Create_field *cf)
{
Create_field *cf){
return createAndRewriteField(a, cf, &tm, false, key_data,
out_list);
});
......@@ -102,18 +96,17 @@ class DropColumnSubHandler : public AlterSubHandler {
class ChangeColumnSubHandler : public AlterSubHandler {
virtual LEX *
rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &preamble)
const
{
const{
FAIL_TextMessageError("implement ChangeColumnSubHandler");
}
};
/*added should update inplace*/
LEX * ForeignKeySubHandler::rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &preamble)
const{
// LEX *const new_lex = copyWithTHD(lex);
TableMeta const &ctm =
a.getTableMeta(preamble.dbname, preamble.table);
//find essential information from froeign key
auto it =
List_iterator<Key>(lex->alter_info.key_list);
......
......@@ -892,13 +892,12 @@ main() {
continue;
}
/*
if(curQuery=="back"){
startBack();
}else{
std::cout<<GREEN_BEGIN<<"curQuery: "<<curQuery<<"\n"<<COLOR_END<<std::endl;
batchTogether(client,curQuery,_thread_id);
}*/
}
std::unique_ptr<SchemaInfo> schema = myLoadSchemaInfo();
processSchemaInfo(*schema);
......
......@@ -425,7 +425,6 @@ nextImpl(const ResType &res, const NextParams &nparams)
TEST_ErrPkt(deltaOutputAfterQuery(nparams.ps.getEConn(), this->deltas,
this->embedded_completion_id.get()),
"deltaOuputAfterQuery failed for DDL");
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
yield return CR_RESULTS(this->ddl_res.get());
}
......
......@@ -66,7 +66,6 @@ void rewriteInsertHelper(const Item &i, const FieldMeta &fm, Analysis &a,
class InsertHandler : public DMLHandler {
virtual void gather(Analysis &a, LEX *const lex) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
//only select xxx etc?不是的!!!
process_select_lex(lex->select_lex, a);
......@@ -232,9 +231,7 @@ class InsertHandler : public DMLHandler {
};
class UpdateHandler : public DMLHandler {
virtual void gather(Analysis &a, LEX *lex) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
virtual void gather(Analysis &a, LEX *lex) const {
process_table_list(lex->select_lex.top_join_list, a);
if (lex->select_lex.item_list.head()) {
......@@ -300,9 +297,7 @@ class UpdateHandler : public DMLHandler {
class DeleteHandler : public DMLHandler {
virtual void gather(Analysis &a, LEX *const lex)
const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const {
process_select_lex(lex->select_lex, a);
}
......@@ -322,16 +317,13 @@ class DeleteHandler : public DMLHandler {
class MultiDeleteHandler : public DMLHandler {
virtual void gather(Analysis &a, LEX *const lex)
const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const {
process_select_lex(lex->select_lex, a);
}
virtual AbstractQueryExecutor *
rewrite(Analysis &a, LEX *lex)
const
{
const {
LEX *const new_lex = copyWithTHD(lex);
// the multidelete looks like this
// $ DELETE <LEX::auxiliary_...> FROM <LEX::query_tables>;
......@@ -444,9 +436,7 @@ class SelectHandler : public DMLHandler {
};
AbstractQueryExecutor *DMLHandler::
transformLex(Analysis &analysis, LEX *lex) const
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
transformLex(Analysis &analysis, LEX *lex) const {
this->gather(analysis, lex);
return this->rewrite(analysis, lex);
}
......@@ -540,7 +530,6 @@ gatherAndAddAnalysisRewritePlanForFieldValuePair(const Item_field &field,
const Item &val,
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[&field] =
std::unique_ptr<RewritePlan>(gather(field, a));
......@@ -555,7 +544,6 @@ static SQL_I_List<ORDER> *
rewrite_order(Analysis &a, const SQL_I_List<ORDER> &lst,
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);
ORDER * prev = NULL;
for (ORDER *o = lst.first; o; o = o->next) {
......@@ -576,7 +564,6 @@ rewrite_order(Analysis &a, const SQL_I_List<ORDER> &lst,
static st_select_lex *
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);
// FIXME: Use const reference for list.
......@@ -604,7 +591,6 @@ rewrite_field_value_pairs(List_iterator<Item> fd_it,
List_iterator<Item> val_it, Analysis &a,
List<Item> *const res_fields,
List<Item> *const res_values) {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
for (;;) {
const Item *const field_item = fd_it++;
const Item *const value_item = val_it++;
......@@ -646,7 +632,6 @@ rewrite_field_value_pairs(List_iterator<Item> fd_it,
static void
addToReturn(ReturnMeta *const rm, int pos, const OLK &constr,
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();
TEST_TextMessageError(test, "ReturnMeta has badly ordered"
" ReturnFields!");
......@@ -660,7 +645,6 @@ addToReturn(ReturnMeta *const rm, int pos, const OLK &constr,
static void
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();
TEST_TextMessageError(test, "ReturnMeta has badly ordered"
" ReturnFields!");
......@@ -674,7 +658,6 @@ addSaltToReturn(ReturnMeta *const rm, int pos)
static void
rewrite_proj(const Item &i, const RewritePlan &rp, Analysis &a,
List<Item> *const newList) {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
AssignOnce<OLK> olk;
AssignOnce<Item *> ir;
......@@ -724,7 +707,6 @@ rewrite_proj(const Item &i, const RewritePlan &rp, Analysis &a,
st_select_lex *
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
// it is responsible for filling Analysis::item_cache which
// rewrite_proj uses.
......@@ -769,7 +751,6 @@ rewrite_select_lex(const st_select_lex &select_lex, Analysis &a)
static void
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);
for (;;) {
const TABLE_LIST *const t = join_it++;
......@@ -795,7 +776,6 @@ static void
process_table_joins_and_derived(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);
for (;;) {
const TABLE_LIST *const t = join_it++;
......@@ -831,7 +811,6 @@ process_table_joins_and_derived(const List<TABLE_LIST> &tll,
void
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.
* 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)
static bool
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()) {
onion const o = om_it.first.getValue();
if (es.osl.find(o) == es.osl.end()) {
......@@ -858,7 +836,6 @@ SIMPLE_UPDATE_TYPE
determineUpdateType(const Item &value_item, const FieldMeta &fm,
const EncSet &es)
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
if (invalidates(fm, es)) {
return SIMPLE_UPDATE_TYPE::UNSUPPORTED;
}
......@@ -883,7 +860,6 @@ doPairRewrite(FieldMeta &fm, const EncSet &es,
List<Item> *const res_fields, List<Item> *const res_values,
Analysis &a)
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const std::unique_ptr<RewritePlan> &field_rp =
constGetAssert(a.rewritePlans,
&static_cast<const Item &>(field_item));
......@@ -909,7 +885,6 @@ addSalt(FieldMeta &fm, const Item_field &field_item,
Analysis &a,
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);
const Item_field * const rew_fd =
static_cast<Item_field *>(res_fields->head());
......@@ -929,11 +904,9 @@ handleUpdateType(SIMPLE_UPDATE_TYPE update_type, const EncSet &es,
List<Item> *const res_fields,
List<Item> *const res_values, Analysis &a)
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
FieldMeta &fm =
a.getFieldMeta(a.getDatabaseName(), field_item.table_name,
field_item.field_name);
switch (update_type) {
case SIMPLE_UPDATE_TYPE::NEW_VALUE: {
bool add_salt = false;
......@@ -1001,13 +974,10 @@ handleUpdateType(SIMPLE_UPDATE_TYPE update_type, const EncSet &es,
class SetHandler : public DMLHandler {
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
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
#define DIRECTIVE_HANDLER(function) \
std::bind((function), this, std::placeholders::_1, \
std::placeholders::_2)
......@@ -1036,7 +1006,6 @@ class SetHandler : public DMLHandler {
switch (v->varType()) {
case set_var_base::V_USER: {
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const set_var_user *const user_v =
static_cast<const set_var_user *>(v);
Item_func_set_user_var *const i =
......@@ -1079,7 +1048,6 @@ class SetHandler : public DMLHandler {
var_pairs[var_name] = var_value;
}
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
// mode; else bad things will happen
const set_var *const set_v =
......@@ -1096,7 +1064,6 @@ class SetHandler : public DMLHandler {
}
case set_var_base::V_PASSWORD:
case set_var_base::V_COLLATION:
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
break;
default:
assert(false);
......@@ -1117,7 +1084,6 @@ private:
handleAdjustDirective(std::map<std::string, std::string> &var_pairs,
Analysis &a) const
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const ParameterCollection &params = collectParameters(var_pairs, a);
for (const auto &it : params.onions) {
......@@ -1140,7 +1106,6 @@ private:
handleShowDirective(std::map<std::string, std::string> &var_pairs,
Analysis &a) const
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
return new ShowDirectiveExecutor(a.getSchema());
}
......@@ -1148,7 +1113,6 @@ private:
handleSensitiveDirective(std::map<std::string, std::string> &var_pairs,
Analysis &a) const
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
assert(a.deltas.size() == 0);
const ParameterCollection &params = collectParameters(var_pairs, a);
......@@ -1173,7 +1137,6 @@ private:
handleKillZoneDirective(std::map<std::string, std::string> &var_pairs,
Analysis &a) const
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
auto count = var_pairs.find(std::string("count"));
auto where = var_pairs.find(std::string("where"));
TEST_Text(var_pairs.end() != count
......@@ -1385,7 +1348,6 @@ nextImpl(const ResType &res, const NextParams &nparams)
static std::pair<std::string, ReturnMeta>
rewriteAndGetFirstQuery(const std::string &query, NextParams nparams)
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
try {
const std::shared_ptr<const SchemaInfo> schema =
nparams.ps.getSchemaInfo();
......@@ -1423,7 +1385,6 @@ nextImpl(const ResType &res, const NextParams &nparams)
crYield(std::make_pair(true, cond_trx));
crEndBlock
*/
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
reenter(this->corot) {
assert(res.success());
......@@ -1606,7 +1567,6 @@ std::pair<AbstractQueryExecutor::ResultType, AbstractAnything *>
ShowDirectiveExecutor::
nextImpl(const ResType &res, const NextParams &nparams)
{
std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
reenter(this->corot) {
yield {
TEST_ErrPkt(deleteAllShowDirectiveEntries(nparams.ps.getEConn()),
......@@ -1662,7 +1622,6 @@ nextImpl(const ResType &res, const NextParams &nparams)
bool ShowDirectiveExecutor::
deleteAllShowDirectiveEntries(const std::unique_ptr<Connect> &e_conn)
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const std::string &query =
"DELETE FROM " + MetaData::Table::showDirective() + ";";
return e_conn->execute(query);
......@@ -1676,7 +1635,6 @@ addShowDirectiveEntry(const std::unique_ptr<Connect> &e_conn,
const std::string &onion,
const std::string &level)
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const std::string &query =
"INSERT INTO " + MetaData::Table::showDirective() +
" (_database, _table, _field, _onion, _level) VALUES "
......@@ -1691,7 +1649,6 @@ bool ShowDirectiveExecutor::
getAllShowDirectiveEntries(const std::unique_ptr<Connect> &e_conn,
std::unique_ptr<DBResult> *db_res)
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
assert(db_res);
const std::string &query =
"SELECT * FROM " + MetaData::Table::showDirective() + ";";
......@@ -1702,7 +1659,6 @@ std::pair<AbstractQueryExecutor::ResultType, AbstractAnything *>
SensitiveDirectiveExecutor::
nextImpl(const ResType &res, const NextParams &nparams)
{
//std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
reenter(this->corot) {
yield {
TEST_ErrPkt(nparams.ps.getEConn()->execute("START TRANSACTION"),
......@@ -1762,9 +1718,6 @@ nextImpl(const ResType &res, const NextParams &nparams)
assert(false);
}
std::pair<AbstractQueryExecutor::ResultType, AbstractAnything *>
ShowCreateTableExecutor::
nextImpl(const ResType &res, const NextParams &nparams){
......@@ -1773,37 +1726,16 @@ nextImpl(const ResType &res, const NextParams &nparams){
reenter(this->corot) {
yield return CR_QUERY_AGAIN(this->query);
TEST_ErrPkt(res.success(), "show create table tables failed");
yield {
//how to find schemaInfo?? we can get it directly
const std::shared_ptr<const SchemaInfo> &schema =
nparams.ps.getSchemaInfo();
const DatabaseMeta *const dm =
schema->getChild(IdentityMetaKey(nparams.default_db));
TEST_ErrPkt(dm, "failed to find the database '"
+ nparams.default_db + "'");
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));
}
}
//avoid reach the end
assert(false);
}
......@@ -22,13 +22,12 @@
#include <util/enum_text.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)
// encrypts a constant item based on the information in a
// encrypts a constant item based on the information in Analysis
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));
FieldMeta * const fm = olk.key;
......
......@@ -22,10 +22,9 @@
#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_)
CItemTypesDir itemTypes = CItemTypesDir();
CItemFuncDir funcTypes = CItemFuncDir();
CItemFuncNameDir funcNames = CItemFuncNameDir();
......@@ -40,8 +39,7 @@ CItemSumFuncDir sumFuncTypes = CItemSumFuncDir();
static std::string
deductPlainTableName(const std::string &field_name,
Name_resolution_context *const context,
Analysis &a)
{
Analysis &a) {
assert(context);
const TABLE_LIST *current_table =
......
......@@ -590,8 +590,6 @@ lowLevelGetCurrentStaleness(const std::unique_ptr<Connect> &e_conn,
const std::string &query =
" SELECT stale FROM " + MetaData::Table::staleness() +
" WHERE cache_id = " + std::to_string(cache_id) + ";";
std::cout<<"query: "<<query<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<std::endl;
std::unique_ptr<DBResult> db_res;
RFIF(e_conn->execute(query, &db_res));
assert(1 == mysql_num_rows(db_res->n));
......
......@@ -3,15 +3,8 @@ OBJDIRS += parser
PARSERSRC := sql_utils.cc lex_util.cc embedmysql.cc \
mysqld-filler.cc mysql_type_metadata.cc
##PARSERPROGS := print-back
##PARSERPROGOBJS := $(pathsubst %, $(OBJDIR)/parser/%,$(PARSERPROGS))
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))
$(OBJDIR)/libedbparser.so: $(EDBPARSER_OBJS) \
......@@ -21,5 +14,4 @@ $(OBJDIR)/libedbparser.so: $(EDBPARSER_OBJS) \
-ledbutil -ledbcrypto \
-Wl,--whole-archive -L$(MYBUILD)/libmysqld -lmysqld \
-Wl,--no-whole-archive -laio -lz -ldl -lrt -lcrypt
# vim: set noexpandtab:
......@@ -23,24 +23,18 @@ using namespace std;
extern "C" void *create_embedded_thd(int client_flag);
void
query_parse::cleanup()
{
// if (annot) {
// delete annot;
// }
query_parse::cleanup(){
if (t) {
t->end_statement();
t->cleanup_after_query();
close_thread_tables(t);
--thread_count;
// t->clear_data_list();
delete t;
t = 0;
}
}
query_parse::~query_parse()
{
query_parse::~query_parse() {
cleanup();
}
......@@ -49,16 +43,6 @@ query_parse::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;
......@@ -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) {
//do not use Annotation now
// annot = new Annotation(q);
return;
} else {
//annot = NULL;
}
try {
//set db
......
......@@ -3,12 +3,8 @@
#include <sstream>
#include <string>
#include <stdexcept>
//#include <parser/Annotation.hh>
#include <util/util.hh>
#include <util/onions.hh>
#include <mysql.h>
#include <sql_base.h>
......@@ -17,12 +13,9 @@ class query_parse {
query_parse(const std::string &db, const std::string &q);
virtual ~query_parse();
LEX *lex();
// Annotation *annot;
private:
void cleanup();
THD *t;
//这里包含了词法分析和语法分析时候, 使用的内部状态.
Parser_state ps;
Parser_state ps; /*这里包含了词法分析和语法分析时候, 使用的内部状态*/
};
......@@ -261,7 +261,6 @@ RiboldMYSQL::get_select_lex(const Item_subselect &i)
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)
{
static const std::string empty_string = "";
......
......@@ -134,11 +134,10 @@ mapList(List_iterator<InType> it, std::function<OutType *(InType *)> op)
return newList;
}
//注意这里的function返回值是List<Type>, 参数是List<Type>以及Type*
/* 注意这里的function返回值是List<Type>, 参数是List<Type>以及Type* */
template <typename Type> List<Type>
accumList(List_iterator<Type> it,
std::function<List<Type>(List<Type>, Type *)> op)
{
std::function<List<Type>(List<Type>, Type *)> op) {
List<Type> accum;
for (Type *element = it++; element ; element = it++) {
......@@ -149,8 +148,7 @@ accumList(List_iterator<Type> it,
}
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>;
for (auto it : v) {
lst->push_back(it);
......@@ -160,8 +158,7 @@ vectorToListWithTHD(std::vector<T *> v)
}
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;
for (Type *element = it++; element ; element = it++) {
......
......@@ -12,8 +12,7 @@ using namespace std;
static bool lib_initialized = false;
void
init_mysql(const string &embed_db)
{
init_mysql(const string &embed_db){
// FIXME: can still get a weird case where something calls
// init_mysql(...) and lib_initialized is true so it continues on to
// execute a query against the embedded database; but the thread
......@@ -41,8 +40,7 @@ init_mysql(const string &embed_db)
}
char *
make_thd_string(const string &s, size_t *lenp)
{
make_thd_string(const string &s, size_t *lenp){
THD *thd = current_thd;
assert(thd);
if (lenp)
......@@ -64,8 +62,7 @@ ItemToString(const Item &i) {
}
std::string
printItemToString(const Item &i)
{
printItemToString(const Item &i){
std::ostringstream o;
o << i;
return o.str();
......
......@@ -562,27 +562,6 @@ enableOrDisableKeysOutput(const LEX &lex)
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
static std::string process_normal_key(LEX &lex){
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