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
421ea7c8
Commit
421ea7c8
authored
Nov 01, 2017
by
Casualet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inserthadandler able to compile
parent
4e3eaaf1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
9 deletions
+99
-9
test_insertHandler.cc
debug/test_insertHandler.cc
+85
-0
dml_handler.cc
main/dml_handler.cc
+6
-8
dml_handler.hh
main/dml_handler.hh
+8
-1
No files found.
debug/test_insertHandler.cc
0 → 100644
View file @
421ea7c8
#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"
;
/*
//Show what Analysis can do
static void test_Analysis(Analysis & analysis){
//oDET,
//oOPE,
//oAGG,
std::cout<<GREEN_BEGIN<<"USE Analysis: "<<COLOR_END<<std::endl;
OnionMeta *om = analysis.getOnionMeta2("tdb","student","id",oDET);
if(om!=NULL)
std::cout<<"use analysis.getOnionMetae oDET: "<<om->getAnonOnionName()<<std::endl;
om = analysis.getOnionMeta2("tdb","student","id",oOPE);
if(om!=NULL)
std::cout<<"use analysis.getOnionMetae oOPE: "<<om->getAnonOnionName()<<std::endl;
om = analysis.getOnionMeta2("tdb","student","id",oAGG);
if(om!=NULL)
std::cout<<"use analysis.getOnionMetae oAGG: "<<om->getAnonOnionName()<<std::endl;
}*/
static
void
myTestCreateTableHandler
(
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
);
//assert(analysis.getMasterKey().get()!=NULL);
//assert(getKey(std::string("113341234"))!=NULL);
//test_Analysis(analysis);
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(1,
\"
zhangfei
\"
)"
;
std
::
vector
<
std
::
string
>
querys
{
query1
};
for
(
auto
item
:
querys
){
std
::
cout
<<
item
<<
std
::
endl
;
myTestCreateTableHandler
(
item
);
std
::
cout
<<
std
::
endl
;
}
return
0
;
}
main/dml_handler.cc
View file @
421ea7c8
...
...
@@ -62,9 +62,7 @@ void rewriteInsertHelper(const Item &i, const FieldMeta &fm, Analysis &a,
}
class
InsertHandler
:
public
DMLHandler
{
virtual
void
gather
(
Analysis
&
a
,
LEX
*
const
lex
)
const
{
void
InsertHandler
::
gather
(
Analysis
&
a
,
LEX
*
const
lex
)
const
{
//only select xxx etc?不是的!!!
process_select_lex
(
lex
->
select_lex
,
a
);
...
...
@@ -79,11 +77,9 @@ class InsertHandler : public DMLHandler {
return
;
}
virtual
AbstractQueryExecutor
*
rewrite
(
Analysis
&
a
,
LEX
*
const
lex
)
const
{
AbstractQueryExecutor
*
InsertHandler
::
rewrite
(
Analysis
&
a
,
LEX
*
const
lex
)
const
{
LEX
*
const
new_lex
=
copyWithTHD
(
lex
);
const
std
::
string
&
table
=
lex
->
select_lex
.
table_list
.
first
->
table_name
;
const
std
::
string
&
db_name
=
...
...
@@ -225,7 +221,9 @@ class InsertHandler : public DMLHandler {
}
return
new
DMLQueryExecutor
(
*
new_lex
,
a
.
rmeta
);
}
};
class
UpdateHandler
:
public
DMLHandler
{
virtual
void
gather
(
Analysis
&
a
,
LEX
*
lex
)
const
{
...
...
main/dml_handler.hh
View file @
421ea7c8
...
...
@@ -15,7 +15,7 @@ public:
~
DMLQueryExecutor
()
{}
std
::
pair
<
ResultType
,
AbstractAnything
*>
nextImpl
(
const
ResType
&
res
,
const
NextParams
&
nparams
);
std
::
string
getQuery
(){
return
query
;}
private
:
const
std
::
string
query
;
const
ReturnMeta
rmeta
;
...
...
@@ -135,5 +135,12 @@ protected:
virtual
~
DMLHandler
()
{;}
};
class
InsertHandler
:
public
DMLHandler
{
virtual
void
gather
(
Analysis
&
a
,
LEX
*
const
lex
)
const
;
virtual
AbstractQueryExecutor
*
rewrite
(
Analysis
&
a
,
LEX
*
const
lex
)
const
;
};
SQLDispatcher
*
buildDMLDispatcher
();
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