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
c2584e9e
Commit
c2584e9e
authored
May 17, 2017
by
casualet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
able to generate simple query
parent
be4ac6f6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1104 additions
and
13 deletions
+1104
-13
Makefile
Makefile
+0
-2
Makefrag
main/Makefrag
+1
-1
cdb_test.cc
main/cdb_test.cc
+19
-10
mbk.cc
main/mbk.cc
+1084
-0
No files found.
Makefile
View file @
c2584e9e
...
@@ -71,12 +71,10 @@ always:
...
@@ -71,12 +71,10 @@ always:
$(OBJDIR)/%.o
:
%.cc
$(OBJDIR)/%.o
:
%.cc
@
mkdir
-p
$
(
@D
)
@
mkdir
-p
$
(
@D
)
$(CXX)
-MD
$(CXXFLAGS)
-c
$<
-o
$@
$(CXX)
-MD
$(CXXFLAGS)
-c
$<
-o
$@
echo
"11111111111111111111111"
$(OBJDIR)/%.o
:
$(OBJDIR)/%.cc
$(OBJDIR)/%.o
:
$(OBJDIR)/%.cc
@
mkdir
-p
$
(
@D
)
@
mkdir
-p
$
(
@D
)
$(CXX)
-MD
$(CXXFLAGS)
-c
$<
-o
$@
$(CXX)
-MD
$(CXXFLAGS)
-c
$<
-o
$@
echo
"2222222222222222222222"
include
crypto/Makefrag
include
crypto/Makefrag
include
parser/Makefrag
include
parser/Makefrag
...
...
main/Makefrag
View file @
c2584e9e
...
@@ -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:= cdb_test
CRYPTDB_PROGS:= cdb_test
mbk
CRYPTDBPROGOBJS := $(patsubst %,$(OBJDIR)/main/%,$(CRYPTDB_PROGS))
CRYPTDBPROGOBJS := $(patsubst %,$(OBJDIR)/main/%,$(CRYPTDB_PROGS))
...
...
main/cdb_test.cc
View file @
c2584e9e
...
@@ -162,6 +162,7 @@ void printrawReturnValue(rawReturnValue & cur) {
...
@@ -162,6 +162,7 @@ void printrawReturnValue(rawReturnValue & cur) {
std
::
cout
<<
"zero output"
<<
std
::
endl
;
std
::
cout
<<
"zero output"
<<
std
::
endl
;
return
;
return
;
}
}
if
(
static_cast
<
int
>
(
cur
.
fieldNames
.
size
())
!=
len
||
static_cast
<
int
>
(
cur
.
rowValues
[
0
].
size
())
!=
len
){
if
(
static_cast
<
int
>
(
cur
.
fieldNames
.
size
())
!=
len
||
static_cast
<
int
>
(
cur
.
rowValues
[
0
].
size
())
!=
len
){
std
::
cout
<<
RED_BEGIN
<<
"size mismatch in printrawReturnValue"
<<
COLOR_END
<<
std
::
endl
;
std
::
cout
<<
RED_BEGIN
<<
"size mismatch in printrawReturnValue"
<<
COLOR_END
<<
std
::
endl
;
return
;
return
;
...
@@ -195,15 +196,13 @@ bool myRewrite(std::string curQuery,unsigned long long _thread_id,std::string cl
...
@@ -195,15 +196,13 @@ bool myRewrite(std::string curQuery,unsigned long long _thread_id,std::string cl
ProxyState
*
const
ps
=
c_wrapper
->
ps
.
get
();
ProxyState
*
const
ps
=
c_wrapper
->
ps
.
get
();
assert
(
ps
);
assert
(
ps
);
c_wrapper
->
last_query
=
curQuery
;
c_wrapper
->
last_query
=
curQuery
;
std
::
cout
<<
RED_BEGIN
<<
"start my rewrite"
<<
COLOR_END
<<
std
::
endl
;
std
::
cout
<<
RED_BEGIN
<<
"start my rewrite"
<<
COLOR_END
<<
std
::
endl
;
try
{
try
{
TEST_Text
(
retrieveDefaultDatabase
(
_thread_id
,
ps
->
getConn
(),
TEST_Text
(
retrieveDefaultDatabase
(
_thread_id
,
ps
->
getConn
(),
&
c_wrapper
->
default_db
),
&
c_wrapper
->
default_db
),
"proxy failed to retrieve default database!"
);
"proxy failed to retrieve default database!"
);
const
std
::
shared_ptr
<
const
SchemaInfo
>
&
schema
=
ps
->
getSchemaInfo
();
const
std
::
shared_ptr
<
const
SchemaInfo
>
&
schema
=
ps
->
getSchemaInfo
();
c_wrapper
->
schema_info_refs
.
push_back
(
schema
);
c_wrapper
->
schema_info_refs
.
push_back
(
schema
);
std
::
unique_ptr
<
QueryRewrite
>
qr
=
std
::
unique_ptr
<
QueryRewrite
>
qr
=
std
::
unique_ptr
<
QueryRewrite
>
(
new
QueryRewrite
(
std
::
unique_ptr
<
QueryRewrite
>
(
new
QueryRewrite
(
Rewriter
::
rewrite
(
curQuery
,
*
schema
.
get
(),
Rewriter
::
rewrite
(
curQuery
,
*
schema
.
get
(),
...
@@ -219,8 +218,7 @@ bool myRewrite(std::string curQuery,unsigned long long _thread_id,std::string cl
...
@@ -219,8 +218,7 @@ bool myRewrite(std::string curQuery,unsigned long long _thread_id,std::string cl
//helper function for transforming the rawReturnValue
//helper function for transforming the rawReturnValue
static
Item_null
*
static
Item_null
*
make_null
(
const
std
::
string
&
name
=
""
)
make_null
(
const
std
::
string
&
name
=
""
){
{
char
*
const
n
=
current_thd
->
strdup
(
name
.
c_str
());
char
*
const
n
=
current_thd
->
strdup
(
name
.
c_str
());
return
new
Item_null
(
n
);
return
new
Item_null
(
n
);
}
}
...
@@ -453,8 +451,10 @@ static std::vector<FieldMeta *> getFieldMeta(SchemaInfo &schema,std::string db =
...
@@ -453,8 +451,10 @@ static std::vector<FieldMeta *> getFieldMeta(SchemaInfo &schema,std::string db =
}
}
}
}
//representation of one field.
struct
transField
{
struct
transField
{
bool
hasSalt
;
bool
hasSalt
;
int
onionIndex
;
int
numOfOnions
;
int
numOfOnions
;
//onions
//onions
std
::
vector
<
std
::
string
>
fields
;
std
::
vector
<
std
::
string
>
fields
;
...
@@ -873,12 +873,14 @@ backupOnionSelection generateBackupStrategy(std::string database, std::string ta
...
@@ -873,12 +873,14 @@ backupOnionSelection generateBackupStrategy(std::string database, std::string ta
//one Olk for each field
//one Olk for each field
backupOnionSelection
curBack
(
fields
.
size
());
backupOnionSelection
curBack
(
fields
.
size
());
int
fieldIndex
=
0
;
int
fieldIndex
=
0
;
//according to uniqueCounter
//according to uniqueCounter
for
(
FieldMeta
*
field
:
tbMeta
->
orderedFieldMetas
())
{
for
(
FieldMeta
*
field
:
tbMeta
->
orderedFieldMetas
()){
curBack
.
fieldSize
[
fieldIndex
]
=
field
->
getChildren
().
size
()
+
1
;
curBack
.
fieldSize
[
fieldIndex
]
=
field
->
getChildren
().
size
()
+
1
;
curBack
.
onionIndex
[
fieldIndex
]
=
0
;
curBack
.
onionIndex
[
fieldIndex
]
=
0
;
fieldIndex
+=
1
;
fieldIndex
+=
1
;
}
}
//complete curBack
//complete curBack
int
num
=
curBack
.
numOfFields
;
int
num
=
curBack
.
numOfFields
;
int
add
=
0
;
int
add
=
0
;
...
@@ -944,6 +946,7 @@ startBack(){
...
@@ -944,6 +946,7 @@ startBack(){
std
::
string
tablename
;
std
::
string
tablename
;
std
::
cin
>>
tablename
;
std
::
cin
>>
tablename
;
backupOnionSelection
curBack
=
generateBackupStrategy
(
dbname
,
tablename
,
*
schema
);
backupOnionSelection
curBack
=
generateBackupStrategy
(
dbname
,
tablename
,
*
schema
);
std
::
shared_ptr
<
ReturnMeta
>
rmeta
=
myGetReturnMeta
(
dbname
,
tablename
,
*
schema
,
curBack
);
std
::
shared_ptr
<
ReturnMeta
>
rmeta
=
myGetReturnMeta
(
dbname
,
tablename
,
*
schema
,
curBack
);
std
::
string
selectQuery
=
logicBackUp
(
dbname
,
tablename
,
*
schema
);
std
::
string
selectQuery
=
logicBackUp
(
dbname
,
tablename
,
*
schema
);
...
@@ -957,6 +960,10 @@ startBack(){
...
@@ -957,6 +960,10 @@ startBack(){
}
}
}
}
int
int
main
()
{
main
()
{
gmp
[
SECLEVEL
::
INVALID
]
=
"INVALID"
;
gmp
[
SECLEVEL
::
INVALID
]
=
"INVALID"
;
...
@@ -967,9 +974,7 @@ main() {
...
@@ -967,9 +974,7 @@ main() {
gmp
[
SECLEVEL
::
DET
]
=
"DET"
;
gmp
[
SECLEVEL
::
DET
]
=
"DET"
;
gmp
[
SECLEVEL
::
SEARCH
]
=
"SEARCH"
;
gmp
[
SECLEVEL
::
SEARCH
]
=
"SEARCH"
;
gmp
[
SECLEVEL
::
HOM
]
=
"HOM"
;
gmp
[
SECLEVEL
::
HOM
]
=
"HOM"
;
gmp
[
SECLEVEL
::
RND
]
=
"RND"
;
gmp
[
SECLEVEL
::
RND
]
=
"RND"
;
gmp2
[
oDET
]
=
"oDET"
;
gmp2
[
oDET
]
=
"oDET"
;
gmp2
[
oOPE
]
=
"oOPE"
;
gmp2
[
oOPE
]
=
"oOPE"
;
gmp2
[
oAGG
]
=
"oAGG"
;
gmp2
[
oAGG
]
=
"oAGG"
;
...
@@ -1017,10 +1022,14 @@ main() {
...
@@ -1017,10 +1022,14 @@ main() {
processSchemaInfo
(
*
schema
);
processSchemaInfo
(
*
schema
);
}
else
if
(
curQuery
==
"back"
){
}
else
if
(
curQuery
==
"back"
){
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
auto
res
=
getTransField
(
getFieldMeta
(
*
schema
));
std
::
vector
<
FieldMeta
*>
fms
=
getFieldMeta
(
*
schema
);
auto
res
=
getTransField
(
fms
);
for
(
auto
&
item
:
res
){
for
(
auto
&
item
:
res
){
item
.
show
();
item
.
show
();
}
}
}
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
);
...
...
main/mbk.cc
0 → 100644
View file @
c2584e9e
This diff is collapsed.
Click to expand it.
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