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
e41f25c6
Commit
e41f25c6
authored
Feb 27, 2018
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test_main
parent
67dae3e7
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
143 additions
and
0 deletions
+143
-0
Makefile
Makefile
+8
-0
.dml_handler_insert.cc.swp
test_main/.dml_handler_insert.cc.swp
+0
-0
Makefrag
test_main/Makefrag
+7
-0
dml_handler_insert.cc
test_main/dml_handler_insert.cc
+63
-0
template.cc
test_main/template.cc
+3
-0
test_insertHandler.cc
test_main/test_insertHandler.cc
+62
-0
No files found.
Makefile
View file @
e41f25c6
...
@@ -101,6 +101,13 @@ mtl/test_parser_exe/%:$(OBJDIR)/test_parser/%.o
...
@@ -101,6 +101,13 @@ mtl/test_parser_exe/%:$(OBJDIR)/test_parser/%.o
@
mkdir
-p
$
(
@D
)
@
mkdir
-p
$
(
@D
)
$(CXX)
-g
-o
$@
$^
$(CXXFLAGS)
$(LDFLAGS)
-L
/
$(MYBUILD)
/libmysqld
-lmysqld
-laio
-lz
-ldl
-lm
-lcrypt
-lpthread
-lcryptdb
-ledbcrypto
-ledbutil
-ledbparser
-lntl
-lcrypto
$(CXX)
-g
-o
$@
$^
$(CXXFLAGS)
$(LDFLAGS)
-L
/
$(MYBUILD)
/libmysqld
-lmysqld
-laio
-lz
-ldl
-lm
-lcrypt
-lpthread
-lcryptdb
-ledbcrypto
-ledbutil
-ledbparser
-lntl
-lcrypto
mtl/test_main_exe/%
:
$(OBJDIR)/test_main/%.o
@
mkdir
-p
$
(
@D
)
$(CXX)
-g
-o
$@
$^
$(CXXFLAGS)
$(LDFLAGS)
-L
/
$(MYBUILD)
/libmysqld
-lmysqld
-laio
-lz
-ldl
-lm
-lcrypt
-lpthread
-lcryptdb
-ledbcrypto
-ledbutil
-ledbparser
-lntl
-lcrypto
include
crypto/Makefrag
include
crypto/Makefrag
include
parser/Makefrag
include
parser/Makefrag
include
main/Makefrag
include
main/Makefrag
...
@@ -111,6 +118,7 @@ include debug/Makefrag
...
@@ -111,6 +118,7 @@ include debug/Makefrag
include
test_wrapper/Makefrag
include
test_wrapper/Makefrag
include
test_util/Makefrag
include
test_util/Makefrag
include
test_parser/Makefrag
include
test_parser/Makefrag
include
test_main/Makefrag
include
wrapper/Makefrag
include
wrapper/Makefrag
...
...
test_main/.dml_handler_insert.cc.swp
0 → 100644
View file @
e41f25c6
File added
test_main/Makefrag
0 → 100644
View file @
e41f25c6
OBJDIRS += test_main
##note that xx=*.cc will not expand. wildcard *.cc will include files from other directories.
##%.o will include testall
TESTALL_OBJS := $(patsubst %.cc,$(OBJDIR)/%.o,$(wildcard test_main/*.cc))
TESTALL_EXES := $(patsubst test_main/%.cc,mtl/test_main_exe/%,$(wildcard test_main/*.cc))
all: $(TESTALL_OBJS) $(TESTALL_EXES)
test_main/dml_handler_insert.cc
0 → 100644
View file @
e41f25c6
#include <iostream>
#include <vector>
#include <functional>
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include <main/Connect.hh>
#include <main/rewrite_util.hh>
#include <main/sql_handler.hh>
#include <main/dml_handler.hh>
#include <main/ddl_handler.hh>
#include <main/CryptoHandlers.hh>
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
static
void
testInsertHandler
(
std
::
string
query
){
std
::
unique_ptr
<
Connect
>
e_conn
(
Connect
::
getEmbedded
(
embeddedDir
));
std
::
unique_ptr
<
SchemaInfo
>
schema
(
new
SchemaInfo
());
std
::
function
<
DBMeta
*
(
DBMeta
*
const
)
>
loadChildren
=
[
&
loadChildren
,
&
e_conn
](
DBMeta
*
const
parent
)
{
auto
kids
=
parent
->
fetchChildren
(
e_conn
);
for
(
auto
it
:
kids
)
{
loadChildren
(
it
);
}
return
parent
;
};
//load all metadata and then store it in schema
loadChildren
(
schema
.
get
());
const
std
::
unique_ptr
<
AES_KEY
>
&
TK
=
std
::
unique_ptr
<
AES_KEY
>
(
getKey
(
std
::
string
(
"113341234"
)));
//just like what we do in Rewrite::rewrite,dispatchOnLex
Analysis
analysis
(
std
::
string
(
"tdb"
),
*
schema
,
TK
,
SECURITY_RATING
::
SENSITIVE
);
DMLHandler
*
h
=
new
InsertHandler
();
std
::
unique_ptr
<
query_parse
>
p
;
p
=
std
::
unique_ptr
<
query_parse
>
(
new
query_parse
(
"tdb"
,
query
));
LEX
*
const
lex
=
p
->
lex
();
auto
executor
=
h
->
transformLex
(
analysis
,
lex
);
std
::
cout
<<
((
DMLQueryExecutor
*
)
executor
)
->
getQuery
()
<<
std
::
endl
;
}
int
main
()
{
char
*
buffer
;
if
((
buffer
=
getcwd
(
NULL
,
0
))
==
NULL
){
perror
(
"getcwd error"
);
}
embeddedDir
=
std
::
string
(
buffer
)
+
"/shadow"
;
const
std
::
string
master_key
=
"113341234"
;
ConnectionInfo
ci
(
"localhost"
,
"root"
,
"letmein"
,
3306
);
SharedProxyState
*
shared_ps
=
new
SharedProxyState
(
ci
,
embeddedDir
,
master_key
,
determineSecurityRating
());
assert
(
shared_ps
!=
NULL
);
std
::
string
query1
=
"insert into student values(NULL)"
;
std
::
vector
<
std
::
string
>
querys
{
query1
};
for
(
auto
item
:
querys
){
std
::
cout
<<
item
<<
std
::
endl
;
testInsertHandler
(
item
);
std
::
cout
<<
std
::
endl
;
}
return
0
;
}
test_main/template.cc
0 → 100644
View file @
e41f25c6
int
main
()
{
return
0
;
}
test_main/test_insertHandler.cc
0 → 100644
View file @
e41f25c6
#include <iostream>
#include <vector>
#include <functional>
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include <main/Connect.hh>
#include <main/rewrite_util.hh>
#include <main/sql_handler.hh>
#include <main/dml_handler.hh>
#include <main/ddl_handler.hh>
#include <main/CryptoHandlers.hh>
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
static
void
testInsertHandler
(
std
::
string
query
){
std
::
unique_ptr
<
Connect
>
e_conn
(
Connect
::
getEmbedded
(
embeddedDir
));
std
::
unique_ptr
<
SchemaInfo
>
schema
(
new
SchemaInfo
());
std
::
function
<
DBMeta
*
(
DBMeta
*
const
)
>
loadChildren
=
[
&
loadChildren
,
&
e_conn
](
DBMeta
*
const
parent
)
{
auto
kids
=
parent
->
fetchChildren
(
e_conn
);
for
(
auto
it
:
kids
)
{
loadChildren
(
it
);
}
return
parent
;
};
//load all metadata and then store it in schema
loadChildren
(
schema
.
get
());
const
std
::
unique_ptr
<
AES_KEY
>
&
TK
=
std
::
unique_ptr
<
AES_KEY
>
(
getKey
(
std
::
string
(
"113341234"
)));
//just like what we do in Rewrite::rewrite,dispatchOnLex
Analysis
analysis
(
std
::
string
(
"tdb"
),
*
schema
,
TK
,
SECURITY_RATING
::
SENSITIVE
);
DMLHandler
*
h
=
new
InsertHandler
();
std
::
unique_ptr
<
query_parse
>
p
;
p
=
std
::
unique_ptr
<
query_parse
>
(
new
query_parse
(
"tdb"
,
query
));
LEX
*
const
lex
=
p
->
lex
();
auto
executor
=
h
->
transformLex
(
analysis
,
lex
);
std
::
cout
<<
((
DMLQueryExecutor
*
)
executor
)
->
getQuery
()
<<
std
::
endl
;
}
int
main
()
{
char
*
buffer
;
if
((
buffer
=
getcwd
(
NULL
,
0
))
==
NULL
){
perror
(
"getcwd error"
);
}
embeddedDir
=
std
::
string
(
buffer
)
+
"/shadow"
;
const
std
::
string
master_key
=
"113341234"
;
ConnectionInfo
ci
(
"localhost"
,
"root"
,
"letmein"
,
3306
);
SharedProxyState
*
shared_ps
=
new
SharedProxyState
(
ci
,
embeddedDir
,
master_key
,
determineSecurityRating
());
assert
(
shared_ps
!=
NULL
);
std
::
string
query1
=
"insert into student values(NULL)"
;
std
::
vector
<
std
::
string
>
querys
{
query1
};
for
(
auto
item
:
querys
){
std
::
cout
<<
item
<<
std
::
endl
;
testInsertHandler
(
item
);
std
::
cout
<<
std
::
endl
;
}
return
0
;
}
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