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
5897071d
Commit
5897071d
authored
Jan 09, 2018
by
yiwenshao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add debug/try_create.cc
parent
b903e65b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
196 additions
and
0 deletions
+196
-0
onionlayout.conf
debug/onionlayout.conf
+0
-0
read_onion_conf.cc
debug/read_onion_conf.cc
+102
-0
test_insertHandler.cc
debug/test_insertHandler.cc
+0
-0
try_create.cc
debug/try_create.cc
+94
-0
No files found.
debug/onionlayout.conf
0 → 100644
View file @
5897071d
debug/read_onion_conf.cc
0 → 100644
View file @
5897071d
#include <stdio.h>
#include <string>
#include <iostream>
#include <vector>
#include <map>
using
namespace
std
;
class
onion_conf
{
string
dir
;
FILE
*
file
;
char
*
buf
;
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>
onions_for_num
;
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>
onions_for_str
;
std
::
vector
<
std
::
string
>
parseline
(
std
::
string
temp
);
void
read_onionlayout_num
(
std
::
string
temp
);
void
read_onionlayout_str
(
std
::
string
temp
);
public
:
onion_conf
(
char
*
filename
);
~
onion_conf
();
};
std
::
vector
<
std
::
string
>
onion_conf
::
parseline
(
std
::
string
temp
){
int
start
=
0
;
int
next
=
0
;
std
::
vector
<
std
::
string
>
res
;
while
(
1
){
char
b
=
temp
.
back
();
if
(
b
==
' '
||
b
==
'\n'
)
temp
.
pop_back
();
else
break
;
}
while
((
next
=
temp
.
find
(
' '
,
start
))
!=-
1
){
res
.
push_back
(
temp
.
substr
(
start
,
next
-
start
));
start
=
next
+
1
;
}
res
.
push_back
(
temp
.
substr
(
start
,
next
-
start
));
return
res
;
}
void
onion_conf
::
read_onionlayout_num
(
std
::
string
temp
){
std
::
vector
<
std
::
string
>
res
=
parseline
(
temp
);
cout
<<
"for num"
<<
endl
;
for
(
auto
item
:
res
){
cout
<<
item
<<
":"
;
}
cout
<<
endl
;
}
void
onion_conf
::
read_onionlayout_str
(
std
::
string
temp
){
std
::
vector
<
std
::
string
>
res
=
parseline
(
temp
);
cout
<<
"for str"
<<
endl
;
for
(
auto
item
:
res
){
cout
<<
item
<<
":"
;
}
cout
<<
endl
;
}
onion_conf
::
onion_conf
(
char
*
f
=
(
char
*
)
"onionlayout.conf"
){
file
=
fopen
(
f
,
"r"
);
if
(
file
==
NULL
)
{
printf
(
"error
\n
"
);
}
buf
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
100
);
string
current_onion
=
"null"
;
size_t
n
;
while
(
getline
(
&
buf
,
&
n
,
file
)
!=-
1
){
string
temp
(
buf
);
if
(
temp
==
string
(
"[onions for num]
\n
"
)){
current_onion
=
"num"
;
continue
;
}
else
if
(
temp
==
string
(
"[onions for str]
\n
"
)){
current_onion
=
"str"
;
continue
;
}
else
if
(
temp
==
string
(
"[end]
\n
"
)){
current_onion
=
"null"
;
continue
;
}
else
if
(
temp
.
size
()
==
0
||
temp
[
0
]
==
'#'
||
temp
[
0
]
==
'\n'
){
continue
;
}
if
(
current_onion
==
string
(
"num"
)){
read_onionlayout_num
(
temp
);
}
else
if
(
current_onion
==
string
(
"str"
)){
read_onionlayout_str
(
temp
);
}
else
{
cout
<<
"error status:"
<<
current_onion
<<
endl
;
return
;
}
}
fclose
(
file
);
free
(
buf
);
}
onion_conf
::~
onion_conf
(){
}
int
main
(){
onion_conf
of
;
return
0
;
}
debug/test_insertHandler
v1
.cc
→
debug/test_insertHandler.cc
View file @
5897071d
File moved
debug/try_create.cc
0 → 100644
View file @
5897071d
/*
To make this work properly, you should at least make sure that the database tdb exists.
*/
#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
myRewriteAndUpdate
(
Analysis
&
a
,
LEX
*
lex
,
std
::
string
db
,
std
::
string
table
){
}
static
void
testCreateTableHandler
(
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
();
myRewriteAndUpdate
(
analysis
,
lex
,
"tdb"
,
"student"
);
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 integer,name varchar(20))"
;
//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
;
testCreateTableHandler
(
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