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
89dafe74
Commit
89dafe74
authored
Apr 13, 2017
by
casualet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check point
parent
75083793
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
21 deletions
+60
-21
ddl_handler.cc
main/ddl_handler.cc
+1
-1
rewrite_main.cc
main/rewrite_main.cc
+2
-18
rewrite_util.cc
main/rewrite_util.cc
+55
-1
rewrite_util.hh
main/rewrite_util.hh
+2
-1
No files found.
main/ddl_handler.cc
View file @
89dafe74
...
@@ -92,7 +92,7 @@ class CreateTableHandler : public DDLHandler {
...
@@ -92,7 +92,7 @@ class CreateTableHandler : public DDLHandler {
// Rewrite INDEX
// Rewrite INDEX
// -----------------------------
// -----------------------------
highLevelRewriteKey
(
*
tm
.
get
(),
*
lex
,
new_lex
,
a
);
highLevelRewriteKey
(
*
tm
.
get
(),
*
lex
,
new_lex
,
a
);
highLevelRewriteForeignKey
();
highLevelRewriteForeignKey
(
*
tm
.
get
(),
*
lex
,
new_lex
,
a
);
// -----------------------------
// -----------------------------
// Update TABLE
// Update TABLE
...
...
main/rewrite_main.cc
View file @
89dafe74
...
@@ -58,7 +58,6 @@ std::string global_crash_point = "";
...
@@ -58,7 +58,6 @@ std::string global_crash_point = "";
void
void
crashTest
(
const
std
::
string
&
current_point
)
{
crashTest
(
const
std
::
string
&
current_point
)
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
if
(
current_point
==
global_crash_point
)
{
if
(
current_point
==
global_crash_point
)
{
throw
CrashTestException
();
throw
CrashTestException
();
}
}
...
@@ -67,7 +66,6 @@ crashTest(const std::string ¤t_point) {
...
@@ -67,7 +66,6 @@ crashTest(const std::string ¤t_point) {
static
inline
std
::
string
static
inline
std
::
string
extract_fieldname
(
Item_field
*
const
i
)
extract_fieldname
(
Item_field
*
const
i
)
{
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
std
::
stringstream
fieldtemp
;
std
::
stringstream
fieldtemp
;
fieldtemp
<<
*
i
;
fieldtemp
<<
*
i
;
return
fieldtemp
.
str
();
return
fieldtemp
.
str
();
...
@@ -76,7 +74,6 @@ extract_fieldname(Item_field *const i)
...
@@ -76,7 +74,6 @@ extract_fieldname(Item_field *const i)
static
bool
static
bool
sanityCheck
(
FieldMeta
&
fm
)
sanityCheck
(
FieldMeta
&
fm
)
{
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
for
(
const
auto
&
it
:
fm
.
getChildren
())
{
for
(
const
auto
&
it
:
fm
.
getChildren
())
{
OnionMeta
*
const
om
=
it
.
second
.
get
();
OnionMeta
*
const
om
=
it
.
second
.
get
();
const
onion
o
=
it
.
first
.
getValue
();
const
onion
o
=
it
.
first
.
getValue
();
...
@@ -93,9 +90,7 @@ sanityCheck(FieldMeta &fm)
...
@@ -93,9 +90,7 @@ sanityCheck(FieldMeta &fm)
static
bool
static
bool
sanityCheck
(
TableMeta
&
tm
)
sanityCheck
(
TableMeta
&
tm
)
{
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
for
(
const
auto
&
it
:
tm
.
getChildren
())
{
for
(
const
auto
&
it
:
tm
.
getChildren
())
{
std
::
cout
<<
__PRETTY_FUNCTION__
<<
":"
<<
__LINE__
<<
":"
<<
__FILE__
<<
":"
<<
__LINE__
<<
std
::
endl
<<
std
::
endl
;
const
auto
&
fm
=
it
.
second
;
const
auto
&
fm
=
it
.
second
;
assert
(
sanityCheck
(
*
fm
.
get
()));
assert
(
sanityCheck
(
*
fm
.
get
()));
}
}
...
@@ -105,9 +100,7 @@ sanityCheck(TableMeta &tm)
...
@@ -105,9 +100,7 @@ sanityCheck(TableMeta &tm)
static
bool
static
bool
sanityCheck
(
DatabaseMeta
&
dm
)
sanityCheck
(
DatabaseMeta
&
dm
)
{
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
for
(
const
auto
&
it
:
dm
.
getChildren
())
{
for
(
const
auto
&
it
:
dm
.
getChildren
())
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const
auto
&
tm
=
it
.
second
;
const
auto
&
tm
=
it
.
second
;
assert
(
sanityCheck
(
*
tm
.
get
()));
assert
(
sanityCheck
(
*
tm
.
get
()));
}
}
...
@@ -117,9 +110,7 @@ sanityCheck(DatabaseMeta &dm)
...
@@ -117,9 +110,7 @@ sanityCheck(DatabaseMeta &dm)
static
bool
static
bool
sanityCheck
(
SchemaInfo
&
schema
)
sanityCheck
(
SchemaInfo
&
schema
)
{
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
for
(
const
auto
&
it
:
schema
.
getChildren
())
{
for
(
const
auto
&
it
:
schema
.
getChildren
())
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
const
auto
&
dm
=
it
.
second
;
const
auto
&
dm
=
it
.
second
;
assert
(
sanityCheck
(
*
dm
.
get
()));
assert
(
sanityCheck
(
*
dm
.
get
()));
}
}
...
@@ -130,7 +121,6 @@ static std::map<std::string, int>
...
@@ -130,7 +121,6 @@ static std::map<std::string, int>
collectTableNames
(
const
std
::
string
&
db_name
,
collectTableNames
(
const
std
::
string
&
db_name
,
const
std
::
unique_ptr
<
Connect
>
&
c
)
const
std
::
unique_ptr
<
Connect
>
&
c
)
{
{
std
::
cout
<<
__PRETTY_FUNCTION__
<<
":"
<<
__LINE__
<<
":"
<<
__FILE__
<<
":"
<<
__LINE__
<<
std
::
endl
<<
std
::
endl
;
std
::
map
<
std
::
string
,
int
>
name_map
;
std
::
map
<
std
::
string
,
int
>
name_map
;
assert
(
c
->
execute
(
"USE "
+
quoteText
(
db_name
)));
assert
(
c
->
execute
(
"USE "
+
quoteText
(
db_name
)));
...
@@ -158,7 +148,6 @@ tablesSanityCheck(SchemaInfo &schema,
...
@@ -158,7 +148,6 @@ tablesSanityCheck(SchemaInfo &schema,
const
std
::
unique_ptr
<
Connect
>
&
e_conn
,
const
std
::
unique_ptr
<
Connect
>
&
e_conn
,
const
std
::
unique_ptr
<
Connect
>
&
conn
)
const
std
::
unique_ptr
<
Connect
>
&
conn
)
{
{
// std::cout<<__PRETTY_FUNCTION__<<":"<<__LINE__<<":"<<__FILE__<<":"<<__LINE__<<std::endl<<std::endl;
for
(
const
auto
&
dm_it
:
schema
.
getChildren
())
{
for
(
const
auto
&
dm_it
:
schema
.
getChildren
())
{
const
auto
&
db_name
=
dm_it
.
first
.
getValue
();
const
auto
&
db_name
=
dm_it
.
first
.
getValue
();
std
::
cout
<<
"db_name: "
<<
db_name
<<
std
::
endl
;
std
::
cout
<<
"db_name: "
<<
db_name
<<
std
::
endl
;
...
@@ -215,7 +204,6 @@ collectRecoveryDetails(const std::unique_ptr<Connect> &conn,
...
@@ -215,7 +204,6 @@ collectRecoveryDetails(const std::unique_ptr<Connect> &conn,
unsigned
long
unfinished_id
,
unsigned
long
unfinished_id
,
std
::
unique_ptr
<
RecoveryDetails
>
*
details
)
std
::
unique_ptr
<
RecoveryDetails
>
*
details
)
{
{
std
::
cout
<<
__PRETTY_FUNCTION__
<<
":"
<<
__LINE__
<<
":"
<<
__FILE__
<<
":"
<<
__LINE__
<<
std
::
endl
<<
std
::
endl
;
// collect completion data
// collect completion data
std
::
unique_ptr
<
DBResult
>
dbres
;
std
::
unique_ptr
<
DBResult
>
dbres
;
const
std
::
string
&
embedded_completion_q
=
const
std
::
string
&
embedded_completion_q
=
...
@@ -1355,21 +1343,17 @@ Rewriter::dispatchOnLex(Analysis &a, const std::string &query)
...
@@ -1355,21 +1343,17 @@ Rewriter::dispatchOnLex(Analysis &a, const std::string &query)
QueryRewrite
QueryRewrite
Rewriter
::
rewrite
(
const
std
::
string
&
q
,
const
SchemaInfo
&
schema
,
Rewriter
::
rewrite
(
const
std
::
string
&
q
,
const
SchemaInfo
&
schema
,
const
std
::
string
&
default_db
,
const
ProxyState
&
ps
)
const
std
::
string
&
default_db
,
const
ProxyState
&
ps
){
{
std
::
cout
<<
__PRETTY_FUNCTION__
<<
":"
<<
__LINE__
<<
":"
<<
__FILE__
<<
":"
<<
__LINE__
<<
std
::
endl
<<
std
::
endl
;
LOG
(
cdb_v
)
<<
"q "
<<
q
;
LOG
(
cdb_v
)
<<
"q "
<<
q
;
assert
(
0
==
mysql_thread_init
());
assert
(
0
==
mysql_thread_init
());
Analysis
analysis
(
default_db
,
schema
,
ps
.
getMasterKey
(),
Analysis
analysis
(
default_db
,
schema
,
ps
.
getMasterKey
(),
ps
.
defaultSecurityRating
());
ps
.
defaultSecurityRating
());
// NOTE: Care what data you try to read from Analysis
// NOTE: Care what data you try to read from Analysis
// at this height.
// at this height.
AbstractQueryExecutor
*
const
executor
=
AbstractQueryExecutor
*
const
executor
=
Rewriter
::
dispatchOnLex
(
analysis
,
q
);
Rewriter
::
dispatchOnLex
(
analysis
,
q
);
if
(
!
executor
)
{
if
(
!
executor
)
{
std
::
cout
<<
"we return noopexecutor here"
<<
__FILE__
<<
":"
<<
__LINE__
<<
std
::
endl
;
return
QueryRewrite
(
true
,
analysis
.
rmeta
,
analysis
.
kill_zone
,
return
QueryRewrite
(
true
,
analysis
.
rmeta
,
analysis
.
kill_zone
,
new
NoOpExecutor
());
new
NoOpExecutor
());
}
}
...
...
main/rewrite_util.cc
View file @
89dafe74
...
@@ -444,10 +444,64 @@ highLevelRewriteKey(const TableMeta &tm, const LEX &seed_lex,
...
@@ -444,10 +444,64 @@ highLevelRewriteKey(const TableMeta &tm, const LEX &seed_lex,
}
}
void
void
highLevelRewriteForeignKey
(){
highLevelRewriteForeignKey
(
const
TableMeta
&
tm
,
const
LEX
&
seed_lex
,
LEX
*
const
out_lex
,
const
Analysis
&
a
){
auto
it
=
List_iterator
<
Key
>
(
out_lex
->
alter_info
.
key_list
);
std
::
vector
<
Key
*>
output_keys
;
while
(
auto
cur
=
it
++
){
if
(
cur
->
type
==
Key
::
FOREIGN_KEY
){
THD
*
cthd
=
current_thd
;
//process current names
Key
*
const
new_key
=
cur
->
clone
(
cthd
->
mem_root
);
std
::
string
new_name
=
"newfk"
;
new_key
->
name
=
string_to_lex_str
(
new_name
);
//process current columns
auto
col_it_cur
=
List_iterator
<
Key_part_spec
>
((
cur
->
columns
));
new_key
->
columns
.
empty
();
/* while(1){
const Key_part_spec *const key_part = col_it_cur++;
if(NULL == key_part){
break;
}
Key_part_spec *const new_key_part = copyWithTHD(key_part);
std::string field_name =
convert_lex_str(new_key_part->field_name);
field_name=std::string("curadd+")+field_name;
new_key_part->field_name = string_to_lex_str(field_name);
new_key->columns.push_back(new_key_part);
}
//process ref columns
auto col_it =
List_iterator<Key_part_spec>(((Foreign_key*)cur)->ref_columns);
((Foreign_key*)new_key)->ref_columns.empty();
while(1){
const Key_part_spec *const key_part = col_it++;
if(NULL == key_part){
break;
}
Key_part_spec *const new_key_part = copyWithTHD(key_part);
std::string field_name =
convert_lex_str(new_key_part->field_name);
field_name=std::string("refadd")+field_name;
new_key_part->field_name = string_to_lex_str(field_name);
((Foreign_key*)new_key)->ref_columns.push_back(new_key_part);
}
//process ref tables
Table_ident* ref_table = ((Foreign_key*)cur)->ref_table;
//Table_ident* new_ref_table = ref_table->clone(cthd->mem_root);
ref_table->table = string_to_lex_str(std::string("hehe_ref"));
//((Foreign_key*)new_key)->ref_table = new_ref_table;
output_keys.push_back(new_key);
*/
}
}
lex
->
alter_info
.
key_list
=
*
vectorToListWithTHD
(
output_keys
);
return
lex
;
}
}
...
...
main/rewrite_util.hh
View file @
89dafe74
...
@@ -55,7 +55,8 @@ highLevelRewriteKey(const TableMeta &tm, const LEX &seed_lex,
...
@@ -55,7 +55,8 @@ highLevelRewriteKey(const TableMeta &tm, const LEX &seed_lex,
//added
//added
void
void
highLevelRewriteForeignKey
();
highLevelRewriteForeignKey
(
const
TableMeta
&
tm
,
const
LEX
&
seed_lex
,
LEX
*
const
out_lex
,
const
Analysis
&
a
);
std
::
string
std
::
string
...
...
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