Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
Practical-Cryptdb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Zhaozhen
Practical-Cryptdb
Commits
9dcd9f88
Commit
9dcd9f88
authored
May 07, 2017
by
Casualet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tweak format
parent
214227cd
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
35 additions
and
197 deletions
+35
-197
Analysis.cc
main/Analysis.cc
+2
-9
Makefrag
main/Makefrag
+1
-1
Translator.cc
main/Translator.cc
+3
-11
alter_sub_handler.cc
main/alter_sub_handler.cc
+6
-13
cdb_test.cc
main/cdb_test.cc
+1
-2
dbobject.tt
main/dbobject.tt
+0
-3
ddl_handler.cc
main/ddl_handler.cc
+0
-1
dml_handler.cc
main/dml_handler.cc
+5
-73
rewrite_const.cc
main/rewrite_const.cc
+3
-4
rewrite_field.cc
main/rewrite_field.cc
+2
-4
schema.cc
main/schema.cc
+0
-2
Makefrag
parser/Makefrag
+0
-8
embedmysql.cc
parser/embedmysql.cc
+3
-22
embedmysql.hh
parser/embedmysql.hh
+2
-9
lex_util.cc
parser/lex_util.cc
+0
-1
lex_util.hh
parser/lex_util.hh
+4
-7
sql_utils.cc
parser/sql_utils.cc
+3
-6
stringify.hh
parser/stringify.hh
+0
-21
No files found.
main/Analysis.cc
View file @
9dcd9f88
...
...
@@ -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
...
...
main/Makefrag
View file @
9dcd9f88
...
...
@@ -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))
...
...
main/Translator.cc
View file @
9dcd9f88
...
...
@@ -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
;
}
main/alter_sub_handler.cc
View file @
9dcd9f88
...
...
@@ -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
);
...
...
main/cdb_test.cc
View file @
9dcd9f88
...
...
@@ -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
);
...
...
main/dbobject.tt
deleted
100644 → 0
View file @
214227cd
#pragma once
main/ddl_handler.cc
View file @
9dcd9f88
...
...
@@ -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
());
}
...
...
main/dml_handler.cc
View file @
9dcd9f88
This diff is collapsed.
Click to expand it.
main/rewrite_const.cc
View file @
9dcd9f88
...
...
@@ -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
;
...
...
main/rewrite_field.cc
View file @
9dcd9f88
...
...
@@ -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
=
...
...
main/schema.cc
View file @
9dcd9f88
...
...
@@ -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
));
...
...
parser/Makefrag
View file @
9dcd9f88
...
...
@@ -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:
parser/embedmysql.cc
View file @
9dcd9f88
...
...
@@ -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
...
...
parser/embedmysql.hh
View file @
9dcd9f88
...
...
@@ -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
;
/*这里包含了词法分析和语法分析时候, 使用的内部状态*/
};
parser/lex_util.cc
View file @
9dcd9f88
...
...
@@ -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
=
""
;
...
...
parser/lex_util.hh
View file @
9dcd9f88
...
...
@@ -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
++
)
{
...
...
parser/sql_utils.cc
View file @
9dcd9f88
...
...
@@ -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
();
...
...
parser/stringify.hh
View file @
9dcd9f88
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment