Commit 3695a861 authored by yiwenshao's avatar yiwenshao

add comments

parent 4ac47930
BasicCrypto.cc
paillier.cc
urandom.cc
arc4.cc
hgd.cc
pbkdf2.cc
ecjoin.cc
ECJoin.cc
search.cc
skip32.cc
ffx.cc
online_ope.cc
mont.cc
prng.cc
ope.cc
SWPSearch.cc
...@@ -373,8 +373,7 @@ SQLDispatcher *buildDDLDispatcher() ...@@ -373,8 +373,7 @@ SQLDispatcher *buildDDLDispatcher()
std::pair<AbstractQueryExecutor::ResultType, AbstractAnything *> std::pair<AbstractQueryExecutor::ResultType, AbstractAnything *>
DDLQueryExecutor:: DDLQueryExecutor::
nextImpl(const ResType &res, const NextParams &nparams) nextImpl(const ResType &res, const NextParams &nparams) {
{
reenter(this->corot) { reenter(this->corot) {
yield { yield {
{ {
...@@ -393,7 +392,6 @@ nextImpl(const ResType &res, const NextParams &nparams) ...@@ -393,7 +392,6 @@ nextImpl(const ResType &res, const NextParams &nparams)
TEST_ErrPkt(res.success(), "DDL query failed"); TEST_ErrPkt(res.success(), "DDL query failed");
// save the results so we can return them to the client // save the results so we can return them to the client
this->ddl_res = res; this->ddl_res = res;
yield { yield {
return CR_QUERY_AGAIN( return CR_QUERY_AGAIN(
" INSERT INTO " + MetaData::Table::remoteQueryCompletion() + " INSERT INTO " + MetaData::Table::remoteQueryCompletion() +
...@@ -402,20 +400,17 @@ nextImpl(const ResType &res, const NextParams &nparams) ...@@ -402,20 +400,17 @@ nextImpl(const ResType &res, const NextParams &nparams)
" '"+TypeText<CompletionType>::toText(CompletionType::Onion)+"'" " '"+TypeText<CompletionType>::toText(CompletionType::Onion)+"'"
" );"); " );");
} }
TEST_ErrPkt(res.success(), "failed issuing ddl completion"); TEST_ErrPkt(res.success(), "failed issuing ddl completion");
// execute the original query against the embedded database // execute the original query against the embedded database
// > this is a ddl query so do not put it into a transaction // > this is a ddl query so do not put it into a transaction
TEST_ErrPkt(nparams.ps.getEConn()->execute(nparams.original_query), TEST_ErrPkt(nparams.ps.getEConn()->execute(nparams.original_query),
"Failed to execute DDL query against embedded database!"); "Failed to execute DDL query against embedded database!");
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");
yield return CR_RESULTS(this->ddl_res.get()); yield return CR_RESULTS(this->ddl_res.get());
} }
assert(false); assert(false);
} }
...@@ -9,12 +9,8 @@ ...@@ -9,12 +9,8 @@
#include <sql_lex.h> #include <sql_lex.h>
class DDLQueryExecutor : public AbstractQueryExecutor { class DDLQueryExecutor : public AbstractQueryExecutor {
AssignOnce<ResType> ddl_res; AssignOnce<ResType> ddl_res;
AssignOnce<uint64_t> embedded_completion_id; AssignOnce<uint64_t> embedded_completion_id;
public: public:
const std::string new_query; const std::string new_query;
DDLQueryExecutor(const LEX &new_lex, DDLQueryExecutor(const LEX &new_lex,
...@@ -23,7 +19,6 @@ public: ...@@ -23,7 +19,6 @@ public:
~DDLQueryExecutor() {} ~DDLQueryExecutor() {}
std::pair<ResultType, AbstractAnything *> std::pair<ResultType, AbstractAnything *>
nextImpl(const ResType &res, const NextParams &nparams); nextImpl(const ResType &res, const NextParams &nparams);
private: private:
const std::vector<std::unique_ptr<Delta> > deltas; const std::vector<std::unique_ptr<Delta> > deltas;
bool stales() const {return true;} bool stales() const {return true;}
...@@ -35,7 +30,6 @@ class DDLHandler : public SQLHandler { ...@@ -35,7 +30,6 @@ class DDLHandler : public SQLHandler {
public: public:
virtual AbstractQueryExecutor *transformLex(Analysis &analysis, LEX *lex) virtual AbstractQueryExecutor *transformLex(Analysis &analysis, LEX *lex)
const; const;
private: private:
virtual AbstractQueryExecutor * virtual AbstractQueryExecutor *
rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &pre) const = 0; rewriteAndUpdate(Analysis &a, LEX *lex, const Preamble &pre) const = 0;
...@@ -44,7 +38,6 @@ protected: ...@@ -44,7 +38,6 @@ protected:
virtual ~DDLHandler() {;} virtual ~DDLHandler() {;}
}; };
class CreateTableHandler : public DDLHandler { class CreateTableHandler : public DDLHandler {
//must rewrite the header here or we get pure virtual function //must rewrite the header here or we get pure virtual function
virtual AbstractQueryExecutor * virtual AbstractQueryExecutor *
...@@ -52,7 +45,4 @@ class CreateTableHandler : public DDLHandler { ...@@ -52,7 +45,4 @@ class CreateTableHandler : public DDLHandler {
}; };
SQLDispatcher *buildDDLDispatcher(); SQLDispatcher *buildDDLDispatcher();
...@@ -27,14 +27,12 @@ class SpecialUpdateExecutor : public AbstractQueryExecutor { ...@@ -27,14 +27,12 @@ class SpecialUpdateExecutor : public AbstractQueryExecutor {
const std::string plain_table; const std::string plain_table;
const std::string crypted_table; const std::string crypted_table;
const std::string where_clause; const std::string where_clause;
// coroutine state // coroutine state
AssignOnce<ResType> dec_res; AssignOnce<ResType> dec_res;
AssignOnce<DBResult *> original_query_dbres; AssignOnce<DBResult *> original_query_dbres;
AssignOnce<std::string> escaped_output_values; AssignOnce<std::string> escaped_output_values;
AssignOnce<ReturnMeta> select_rmeta; AssignOnce<ReturnMeta> select_rmeta;
AssignOnce<bool> in_trx; AssignOnce<bool> in_trx;
public: public:
SpecialUpdateExecutor(const std::string &plain_table, SpecialUpdateExecutor(const std::string &plain_table,
const std::string &crypted_table, const std::string &crypted_table,
...@@ -154,7 +152,3 @@ rewrite_field_value_pairs(List_iterator<Item> fd_it, ...@@ -154,7 +152,3 @@ 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);
...@@ -19,9 +19,7 @@ genericPreamble(const NextParams &nparams) ...@@ -19,9 +19,7 @@ genericPreamble(const NextParams &nparams)
// We handle before any queries because a failed query // We handle before any queries because a failed query
// may stale the database during recovery and then // may stale the database during recovery and then
// we'd have to handle there as well. // we'd have to handle there as well.
//stales, if set true, will set the cache status to stale, which triggers the reloading of metadata. The default value of stale, which is from AbstractQueryExecutor, is false.
//首先根据stales来设置这个executor会不会让当前在shared中的cache变成stale,对于simple来说, 继承的是默认的情况, 所以
//不会设置cache为stale, 也就是下次进入rewrite的时候, 不需要重新load.
try { try {
nparams.ps.getSchemaCache().updateStaleness( nparams.ps.getSchemaCache().updateStaleness(
nparams.ps.getEConn(), this->stales()); nparams.ps.getEConn(), this->stales());
......
#pragma once #pragma once
#include <main/Analysis.hh> #include <main/Analysis.hh>
#include <util/yield.hpp> #include <util/yield.hpp>
#include <sql_lex.h> #include <sql_lex.h>
#include <map> #include <map>
#define CR_QUERY_AGAIN(query) \ #define CR_QUERY_AGAIN(query) \
...@@ -25,7 +22,6 @@ class Anything; ...@@ -25,7 +22,6 @@ class Anything;
class AbstractAnything { class AbstractAnything {
public: public:
virtual ~AbstractAnything() = 0; virtual ~AbstractAnything() = 0;
template <typename Type> template <typename Type>
Type Type
extract() const extract() const
...@@ -62,22 +58,18 @@ struct NextParams { ...@@ -62,22 +58,18 @@ struct NextParams {
class AbstractQueryExecutor { class AbstractQueryExecutor {
protected: protected:
coroutine corot; coroutine corot;
public: public:
enum class ResultType {RESULTS, QUERY_COME_AGAIN, QUERY_USE_RESULTS}; enum class ResultType {RESULTS, QUERY_COME_AGAIN, QUERY_USE_RESULTS};
AbstractQueryExecutor() {} AbstractQueryExecutor() {}
virtual ~AbstractQueryExecutor(); virtual ~AbstractQueryExecutor();
std::pair<ResultType, AbstractAnything *> std::pair<ResultType, AbstractAnything *>
next(const ResType &res, const NextParams &nparams); next(const ResType &res, const NextParams &nparams);
virtual std::pair<ResultType, AbstractAnything *> virtual std::pair<ResultType, AbstractAnything *>
nextImpl(const ResType &res, const NextParams &nparams) = 0; nextImpl(const ResType &res, const NextParams &nparams) = 0;
//true will set the staleness of the current cache id to true, which results in a reloading of schemaInfo //true will set the staleness of the current cache id to true, which results in a reloading of schemaInfo
virtual bool stales() const {return false;} virtual bool stales() const {return false;}
//if usesEmbedded is true, then the current db of the embedded MySQL is set to embedded_db //if usesEmbedded is true, then the current db of the embedded MySQL is set to embedded_db
virtual bool usesEmbedded() const {return false;} virtual bool usesEmbedded() const {return false;}
private: private:
void genericPreamble(const NextParams &nparams); void genericPreamble(const NextParams &nparams);
}; };
...@@ -95,7 +87,6 @@ class NoOpExecutor : public AbstractQueryExecutor { ...@@ -95,7 +87,6 @@ class NoOpExecutor : public AbstractQueryExecutor {
public: public:
NoOpExecutor() {} NoOpExecutor() {}
~NoOpExecutor() {} ~NoOpExecutor() {}
std::pair<ResultType, AbstractAnything *> std::pair<ResultType, AbstractAnything *>
nextImpl(const ResType &res, const NextParams &nparams); nextImpl(const ResType &res, const NextParams &nparams);
}; };
......
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