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
828596ea
Commit
828596ea
authored
Oct 30, 2017
by
Casualet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify test_createHandler
parent
15c0202c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
5 deletions
+81
-5
test_createHandler.cc
debug/test_createHandler.cc
+81
-0
test_load_schema.cc
debug/test_load_schema.cc
+0
-5
No files found.
debug/test_createHandler.cc
0 → 100644
View file @
828596ea
#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
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);
DDLHandler
*
h
=
new
CreateTableHandler
();
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
<<
((
DDLQueryExecutor
*
)
executor
)
->
new_query
<<
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
=
"CREATE TABLE child (id decimal)"
;
std
::
string
query2
=
"CREATE TABLE child (id tinyint)"
;
std
::
string
query3
=
"CREATE TABLE child (id mediumint)"
;
std
::
string
query4
=
"CREATE TABLE child (id smallint)"
;
std
::
string
query5
=
"CREATE TABLE child (id int)"
;
std
::
string
query6
=
"CREATE TABLE child (id bigint)"
;
std
::
string
query7
=
"CREATE TABLE child (name varchar(100))"
;
std
::
string
query8
=
"CREATE TABLE child (name varchar(1000))"
;
std
::
string
query9
=
"CREATE TABLE child (name varchar(10000))"
;
std
::
vector
<
std
::
string
>
querys
{
query1
,
query2
,
query3
,
query4
,
query5
,
query6
,
query7
,
query8
,
query9
};
for
(
auto
item
:
querys
){
std
::
cout
<<
item
<<
std
::
endl
;
myTestCreateTableHandler
(
item
);
std
::
cout
<<
std
::
endl
;
}
return
0
;
}
debug/test_load_schema.cc
View file @
828596ea
...
...
@@ -21,7 +21,6 @@ class WrapperState {
public
:
std
::
string
last_query
;
std
::
string
default_db
;
WrapperState
()
{}
~
WrapperState
()
{}
const
std
::
unique_ptr
<
QueryRewrite
>
&
getQueryRewrite
()
const
{
...
...
@@ -44,13 +43,9 @@ public:
private
:
std
::
unique_ptr
<
QueryRewrite
>
qr
;
};
//global map, for each client, we have one WrapperState which contains ProxyState.
static
std
::
map
<
std
::
string
,
WrapperState
*>
clients
;
//This connection mimics the behaviour of MySQL-Proxy
Connect
*
globalConn
;
static
void
processFieldMeta
(
const
FieldMeta
&
field
){
std
::
cout
<<
GREEN_BEGIN
<<
"PRINT FieldMeta"
<<
COLOR_END
<<
std
::
endl
;
for
(
const
auto
&
onion
:
field
.
getChildren
()){
...
...
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