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
ad309c86
Commit
ad309c86
authored
May 26, 2017
by
casualet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
able to show all columns
parent
e1a77857
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
139 additions
and
113 deletions
+139
-113
mbk.cc
main/mbk.cc
+92
-113
intnormal.sh
packages/tls/intnormal.sh
+47
-0
No files found.
main/mbk.cc
View file @
ad309c86
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
#include <util/enum_text.hh>
#include <util/enum_text.hh>
#include <util/yield.hpp>
#include <util/yield.hpp>
#include<util/timer.hh>
#include <sstream>
#include <sstream>
#include <unistd.h>
#include <unistd.h>
#include <map>
#include <map>
...
@@ -57,6 +58,10 @@ static const int numOfPipe = 1;
...
@@ -57,6 +58,10 @@ static const int numOfPipe = 1;
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
vector
<
bool
>
whetherToQuoteGlobal
;
//My WrapperState.
//My WrapperState.
class
WrapperState
{
class
WrapperState
{
WrapperState
(
const
WrapperState
&
other
);
WrapperState
(
const
WrapperState
&
other
);
...
@@ -478,40 +483,14 @@ std::shared_ptr<ReturnMeta> getReturnMeta(std::vector<FieldMeta*> fms, std::vect
...
@@ -478,40 +483,14 @@ std::shared_ptr<ReturnMeta> getReturnMeta(std::vector<FieldMeta*> fms, std::vect
static
static
std
::
string
getBackupQuery
(
SchemaInfo
&
schema
,
std
::
vector
<
transField
>
&
tfds
,
std
::
string
getBackupQuery
(
SchemaInfo
&
schema
,
std
::
vector
<
transField
>
&
tfds
,
std
::
string
db
=
"tdb"
,
std
::
string
table
=
"student1"
)
{
std
::
string
db
=
"tdb"
,
std
::
string
table
=
"student1"
,
bool
withHex
=
false
,
bool
withSalt
=
true
)
{
std
::
string
res
=
"SELECT "
;
const
std
::
unique_ptr
<
IdentityMetaKey
>
dbmeta_key
(
new
IdentityMetaKey
(
db
));
//get databaseMeta, search in the map
DatabaseMeta
*
dbm
=
schema
.
getChild
(
*
dbmeta_key
);
const
TableMeta
&
tbm
=
*
((
*
dbm
).
getChild
(
IdentityMetaKey
(
table
)));
std
::
string
annotablename
=
tbm
.
getAnonTableName
();
//then a list of onion names
for
(
auto
item
:
tfds
){
for
(
auto
index
:
item
.
choosenOnions
){
res
+=
std
::
string
(
"hex("
)
+
item
.
fields
[
index
]
+
")"
;
res
+=
" , "
;
}
if
(
item
.
hasSalt
){
res
+=
string
(
"hex("
)
+
item
.
originalFm
->
getSaltName
()
+
") , "
;
}
}
res
=
res
.
substr
(
0
,
res
.
size
()
-
2
);
res
=
res
+
"FROM `"
+
db
+
std
::
string
(
"`.`"
)
+
annotablename
+
"`"
;
return
res
;
}
static
std
::
string
getBackupQueryWithoutSalt
(
SchemaInfo
&
schema
,
std
::
vector
<
transField
>
&
tfds
,
std
::
string
db
=
"tdb"
,
std
::
string
table
=
"student1"
)
{
std
::
string
res
=
"SELECT "
;
std
::
string
res
=
"SELECT "
;
const
std
::
unique_ptr
<
IdentityMetaKey
>
dbmeta_key
(
new
IdentityMetaKey
(
db
));
const
std
::
unique_ptr
<
IdentityMetaKey
>
dbmeta_key
(
new
IdentityMetaKey
(
db
));
//get databaseMeta, search in the map
//get databaseMeta, search in the map
DatabaseMeta
*
dbm
=
schema
.
getChild
(
*
dbmeta_key
);
DatabaseMeta
*
dbm
=
schema
.
getChild
(
*
dbmeta_key
);
const
TableMeta
&
tbm
=
*
((
*
dbm
).
getChild
(
IdentityMetaKey
(
table
)));
const
TableMeta
&
tbm
=
*
((
*
dbm
).
getChild
(
IdentityMetaKey
(
table
)));
std
::
string
annotablename
=
tbm
.
getAnonTableName
();
std
::
string
annotablename
=
tbm
.
getAnonTableName
();
int
numOfChoosenField
=
0
;
int
numOfChoosenField
=
0
;
//then a list of onion names
//then a list of onion names
for
(
auto
item
:
tfds
){
for
(
auto
item
:
tfds
){
...
@@ -536,76 +515,32 @@ std::string getBackupQueryWithoutSalt(SchemaInfo &schema, std::vector<transField
...
@@ -536,76 +515,32 @@ std::string getBackupQueryWithoutSalt(SchemaInfo &schema, std::vector<transField
for
(
auto
item
:
tfds
){
for
(
auto
item
:
tfds
){
for
(
auto
index
:
item
.
choosenOnions
){
for
(
auto
index
:
item
.
choosenOnions
){
if
(
whetherToQuote
[
fieldIndex
]){
if
(
whetherToQuote
[
fieldIndex
]){
res
+=
string
(
"QUOTE("
)
+
item
.
fields
[
index
]
+
")"
;
if
(
!
withHex
){
res
+=
" , "
;
res
+=
string
(
"QUOTE("
)
+
item
.
fields
[
index
]
+
") AS Q"
+
item
.
fields
[
index
];
res
+=
" , "
;
}
else
{
res
+=
string
(
"HEX("
)
+
item
.
fields
[
index
]
+
") AS H"
+
item
.
fields
[
index
];
res
+=
" , "
;
}
}
else
{
}
else
{
res
+=
item
.
fields
[
index
];
res
+=
item
.
fields
[
index
];
res
+=
" , "
;
res
+=
" , "
;
}
}
fieldIndex
++
;
fieldIndex
++
;
}
}
}
if
(
item
.
hasSalt
&&
withSalt
){
res
=
res
.
substr
(
0
,
res
.
size
()
-
2
);
res
+=
item
.
originalFm
->
getSaltName
()
+
" , "
;
res
+=
"FROM `"
+
db
+
std
::
string
(
"`.`"
)
+
annotablename
+
"`"
;
return
res
;
}
static
std
::
string
getBackupQueryWithoutSaltHex
(
SchemaInfo
&
schema
,
std
::
vector
<
transField
>
&
tfds
,
std
::
string
db
=
"tdb"
,
std
::
string
table
=
"student1"
)
{
std
::
string
res
=
"SELECT "
;
const
std
::
unique_ptr
<
IdentityMetaKey
>
dbmeta_key
(
new
IdentityMetaKey
(
db
));
//get databaseMeta, search in the map
DatabaseMeta
*
dbm
=
schema
.
getChild
(
*
dbmeta_key
);
const
TableMeta
&
tbm
=
*
((
*
dbm
).
getChild
(
IdentityMetaKey
(
table
)));
std
::
string
annotablename
=
tbm
.
getAnonTableName
();
int
numOfChoosenField
=
0
;
//then a list of onion names
for
(
auto
item
:
tfds
){
for
(
auto
index
:
item
.
choosenOnions
){
res
+=
item
.
fields
[
index
];
res
+=
" , "
;
numOfChoosenField
++
;
}
}
res
=
res
.
substr
(
0
,
res
.
size
()
-
2
);
res
=
res
+
"FROM `"
+
db
+
std
::
string
(
"`.`"
)
+
annotablename
+
"` limit 1;"
;
rawReturnValue
resraw
=
executeAndGetResultRemote
(
globalConn
,
res
);
assert
(
numOfChoosenField
==
(
int
)
resraw
.
fieldTypes
.
size
());
vector
<
bool
>
whetherToQuote
;
for
(
auto
i
=
0u
;
i
<
resraw
.
fieldTypes
.
size
();
i
++
){
if
(
IS_NUM
(
resraw
.
fieldTypes
[
i
]))
whetherToQuote
.
push_back
(
false
);
else
whetherToQuote
.
push_back
(
true
);
}
int
fieldIndex
=
0
;
res
=
"SELECT "
;
for
(
auto
item
:
tfds
){
for
(
auto
index
:
item
.
choosenOnions
){
if
(
whetherToQuote
[
fieldIndex
]){
res
+=
string
(
"HEX("
)
+
item
.
fields
[
index
]
+
")"
;
res
+=
" , "
;
}
else
{
res
+=
item
.
fields
[
index
];
res
+=
" , "
;
}
fieldIndex
++
;
}
}
}
}
whetherToQuoteGlobal
=
whetherToQuote
;
res
=
res
.
substr
(
0
,
res
.
size
()
-
2
);
res
=
res
.
substr
(
0
,
res
.
size
()
-
2
);
res
+=
"FROM `"
+
db
+
std
::
string
(
"`.`"
)
+
annotablename
+
"`"
;
res
=
res
+
"FROM `"
+
db
+
std
::
string
(
"`.`"
)
+
annotablename
+
"`"
;
return
res
;
return
res
;
}
}
static
static
std
::
string
getInsertQuery
(
SchemaInfo
&
schema
,
std
::
vector
<
transField
>
&
tfds
,
std
::
string
getInsertQuery
(
SchemaInfo
&
schema
,
std
::
vector
<
transField
>
&
tfds
,
std
::
string
db
,
std
::
string
table
,
rawReturnValue
&
rows
){
std
::
string
db
,
std
::
string
table
,
rawReturnValue
&
rows
,
bool
isHex
=
false
){
std
::
string
res
=
"INSERT INTO "
;
std
::
string
res
=
"INSERT INTO "
;
const
std
::
unique_ptr
<
IdentityMetaKey
>
dbmeta_key
(
new
IdentityMetaKey
(
db
));
const
std
::
unique_ptr
<
IdentityMetaKey
>
dbmeta_key
(
new
IdentityMetaKey
(
db
));
//get databaseMeta, search in the map
//get databaseMeta, search in the map
...
@@ -613,16 +548,18 @@ std::string getInsertQuery(SchemaInfo &schema, std::vector<transField> &tfds,
...
@@ -613,16 +548,18 @@ std::string getInsertQuery(SchemaInfo &schema, std::vector<transField> &tfds,
const
TableMeta
&
tbm
=
*
((
*
dbm
).
getChild
(
IdentityMetaKey
(
table
)));
const
TableMeta
&
tbm
=
*
((
*
dbm
).
getChild
(
IdentityMetaKey
(
table
)));
std
::
string
annotablename
=
tbm
.
getAnonTableName
();
std
::
string
annotablename
=
tbm
.
getAnonTableName
();
//Those are just headers
//Those are just headers
res
+=
std
::
string
(
"`"
)
+
db
+
std
::
string
(
"`.`"
)
+
annotablename
+
"` VALUES
"
;
res
+=
std
::
string
(
"`"
)
+
annotablename
+
"` VALUES
"
;
int
startIndex
=
0
;
int
startIndex
=
0
;
while
(
startIndex
<
(
int
)
rows
.
rowValues
.
size
()){
while
(
startIndex
<
(
int
)
rows
.
rowValues
.
size
()){
string
manyValues
=
"(
"
;
string
manyValues
=
"("
;
//first
//first
if
(
startIndex
<
(
int
)
rows
.
rowValues
.
size
()){
if
(
startIndex
<
(
int
)
rows
.
rowValues
.
size
()){
vector
<
string
>
&
curStringVec
=
rows
.
rowValues
[
startIndex
];
vector
<
string
>
&
curStringVec
=
rows
.
rowValues
[
startIndex
];
for
(
auto
item
:
curStringVec
){
for
(
auto
item
:
curStringVec
){
manyValues
+=
string
(
"0x"
)
+
item
+
","
;
if
(
!
isHex
)
manyValues
+=
item
+
","
;
else
manyValues
+=
string
(
"0x"
)
+
item
+
","
;
}
}
}
}
//finish first query.
//finish first query.
...
@@ -635,7 +572,9 @@ std::string getInsertQuery(SchemaInfo &schema, std::vector<transField> &tfds,
...
@@ -635,7 +572,9 @@ std::string getInsertQuery(SchemaInfo &schema, std::vector<transField> &tfds,
vector
<
string
>
&
curStringVec
=
rows
.
rowValues
[
++
startIndex
];
vector
<
string
>
&
curStringVec
=
rows
.
rowValues
[
++
startIndex
];
manyValues
+=
", ("
;
manyValues
+=
", ("
;
for
(
auto
item
:
curStringVec
){
for
(
auto
item
:
curStringVec
){
manyValues
+=
string
(
"0x"
)
+
item
+
","
;
if
(
!
isHex
)
manyValues
+=
item
+
","
;
else
manyValues
+=
string
(
"0x"
)
+
item
+
","
;
}
}
manyValues
[
manyValues
.
size
()
-
1
]
=
')'
;
manyValues
[
manyValues
.
size
()
-
1
]
=
')'
;
}
}
...
@@ -673,26 +612,60 @@ std::string getTestQuery(SchemaInfo &schema, std::vector<transField> &tfds,
...
@@ -673,26 +612,60 @@ std::string getTestQuery(SchemaInfo &schema, std::vector<transField> &tfds,
return
res
;
return
res
;
}
}
static
void
writeResultsColumns
(
rawReturnValue
&
raw
){
system
(
"rm -rf allColumns"
);
system
(
"mkdir allColumns"
);
vector
<
FILE
*>
files
;
for
(
auto
i
=
0u
;
i
<
raw
.
fieldNames
.
size
();
i
++
){
FILE
*
cur
=
fopen
((
string
(
"allColumns/"
)
+
raw
.
fieldNames
[
i
]).
c_str
(),
"w"
);
if
(
cur
==
NULL
)
exit
(
1
);
files
.
push_back
(
cur
);
}
//write each columns to each file;
for
(
auto
i
=
0u
;
i
<
raw
.
fieldNames
.
size
();
i
++
){
for
(
auto
item
:
raw
.
rowValues
){
fwrite
(
item
[
i
].
c_str
(),
1
,
item
[
i
].
size
(),
files
[
i
]);
fprintf
(
files
[
i
],
"
\n
"
);
}
}
for
(
auto
i
=
0u
;
i
<
files
.
size
();
i
++
)
fclose
(
files
[
i
]);
}
int
int
main
(
int
argc
,
char
*
argv
[])
{
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
4
){
if
(
argc
!=
5
){
for
(
int
i
=
0
;
i
<
argc
;
i
++
){
for
(
int
i
=
0
;
i
<
argc
;
i
++
){
printf
(
"%s
\n
"
,
argv
[
i
]);
printf
(
"%s
\n
"
,
argv
[
i
]);
}
}
cout
<<
"./mbk dbname tablename option
\n
"
cout
<<
"./mbk dbname tablename option
\n
"
"0. back up and decrypt
\n
"
"0. back up and decrypt
\n
"
"1. back up all With Salt
\n
"
"1. back up all
onions
With Salt
\n
"
"2. back up the first onion
with out dealing with quote
With salt
\n
"
"2. back up the first onion With salt
\n
"
"3. back up the first onion
while dealing with quote Without Salt
\n
"
"3. back up the first onion
Without salt
\n
"
"4. back up
the first onion while dealing with hex Without salt
\n
"
"4. back up
all onions and salts in a hirechy
\n
"
"5. to be implemented
\n
"
"5. to be implemented
\n
"
<<
endl
;
<<
endl
;
return
0
;
return
0
;
}
}
string
hexstring
(
argv
[
4
]);
bool
useHex
=
false
;
if
(
hexstring
==
"hex"
){
useHex
=
true
;
}
else
if
(
hexstring
==
"quote"
){
useHex
=
false
;
}
else
return
0
;
const
char
*
filename
=
"results"
;
FILE
*
stream
=
fopen
(
filename
,
"w"
);
if
(
stream
==
NULL
){
fclose
(
stream
);
return
0
;
}
gmp
[
SECLEVEL
::
INVALID
]
=
"INVALID"
;
gmp
[
SECLEVEL
::
INVALID
]
=
"INVALID"
;
gmp
[
SECLEVEL
::
PLAINVAL
]
=
"PLAINVAL"
;
gmp
[
SECLEVEL
::
PLAINVAL
]
=
"PLAINVAL"
;
gmp
[
SECLEVEL
::
OPE
]
=
"OPE"
;
gmp
[
SECLEVEL
::
OPE
]
=
"OPE"
;
...
@@ -751,12 +724,8 @@ main(int argc, char* argv[]) {
...
@@ -751,12 +724,8 @@ main(int argc, char* argv[]) {
ResType
rawtorestype
=
MygetResTypeFromLuaTable
(
false
,
&
resraw
);
ResType
rawtorestype
=
MygetResTypeFromLuaTable
(
false
,
&
resraw
);
auto
finalresults
=
decryptResults
(
rawtorestype
,
*
rm
);
auto
finalresults
=
decryptResults
(
rawtorestype
,
*
rm
);
parseResType
(
finalresults
);
parseResType
(
finalresults
);
}
else
if
(
string
(
argv
[
3
])
==
"1"
){
}
else
if
(
string
(
argv
[
3
])
==
"1"
){
//back up all the onions and salts
std
::
string
db
,
table
;
std
::
string
db
(
argv
[
1
]),
table
(
argv
[
2
]);
std
::
cout
<<
"please input dbname "
<<
std
::
endl
;
cin
>>
db
;
std
::
cout
<<
"please input table name "
<<
std
::
endl
;
cin
>>
table
;
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
//get all the fields in the tables.
//get all the fields in the tables.
std
::
vector
<
FieldMeta
*>
fms
=
getFieldMeta
(
*
schema
,
db
,
table
);
std
::
vector
<
FieldMeta
*>
fms
=
getFieldMeta
(
*
schema
,
db
,
table
);
...
@@ -771,11 +740,11 @@ main(int argc, char* argv[]) {
...
@@ -771,11 +740,11 @@ main(int argc, char* argv[]) {
item
.
choosenOnions
.
push_back
(
i
);
item
.
choosenOnions
.
push_back
(
i
);
}
}
}
}
std
::
string
backq
=
getBackupQuery
(
*
schema
,
res
,
db
,
table
);
std
::
string
backq
=
getBackupQuery
(
*
schema
,
res
,
db
,
table
,
useHex
,
true
);
cout
<<
backq
<<
endl
;
cout
<<
backq
<<
endl
;
rawReturnValue
resraw
=
executeAndGetResultRemote
(
globalConn
,
backq
);
rawReturnValue
resraw
=
executeAndGetResultRemote
(
globalConn
,
backq
);
getInsertQuery
(
*
schema
,
res
,
db
,
table
,
resraw
);
getInsertQuery
(
*
schema
,
res
,
db
,
table
,
resraw
);
}
else
if
(
string
(
argv
[
3
])
==
"2"
){
}
else
if
(
string
(
argv
[
3
])
==
"2"
){
//backup onion det with salt
std
::
string
db
(
argv
[
1
]),
table
(
argv
[
2
]);
std
::
string
db
(
argv
[
1
]),
table
(
argv
[
2
]);
std
::
cout
<<
db
<<
":"
<<
table
<<
std
::
endl
;
std
::
cout
<<
db
<<
":"
<<
table
<<
std
::
endl
;
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
...
@@ -790,11 +759,14 @@ main(int argc, char* argv[]) {
...
@@ -790,11 +759,14 @@ main(int argc, char* argv[]) {
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
+
1
);
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
+
1
);
item
.
choosenOnions
.
push_back
(
0
);
item
.
choosenOnions
.
push_back
(
0
);
}
}
std
::
string
backq
=
getBackupQuery
(
*
schema
,
res
,
db
,
table
);
std
::
string
backq
=
getBackupQuery
(
*
schema
,
res
,
db
,
table
,
useHex
,
true
);
cout
<<
backq
<<
endl
;
cout
<<
backq
<<
endl
;
timer
t
;
rawReturnValue
resraw
=
executeAndGetResultRemote
(
globalConn
,
backq
);
rawReturnValue
resraw
=
executeAndGetResultRemote
(
globalConn
,
backq
);
fprintf
(
stream
,
"2: time to get rows : %.4lf
\n
"
,
t
.
lap
()
*
1.0
/
1000000
);
getInsertQuery
(
*
schema
,
res
,
db
,
table
,
resraw
);
getInsertQuery
(
*
schema
,
res
,
db
,
table
,
resraw
);
}
else
if
(
string
(
argv
[
3
])
==
"3"
){
fprintf
(
stream
,
"2: time to sync inserts : %.4lf
\n
"
,
t
.
lap
()
*
1.0
/
1000000
);
}
else
if
(
string
(
argv
[
3
])
==
"3"
){
//backup onion det without salt
std
::
string
db
(
argv
[
1
]),
table
(
argv
[
2
]);
std
::
string
db
(
argv
[
1
]),
table
(
argv
[
2
]);
std
::
cout
<<
db
<<
":"
<<
table
<<
std
::
endl
;
std
::
cout
<<
db
<<
":"
<<
table
<<
std
::
endl
;
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
...
@@ -808,14 +780,16 @@ main(int argc, char* argv[]) {
...
@@ -808,14 +780,16 @@ main(int argc, char* argv[]) {
assert
(
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
||
assert
(
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
||
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
+
1
);
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
+
1
);
item
.
choosenOnions
.
push_back
(
0
);
item
.
choosenOnions
.
push_back
(
0
);
}
}
std
::
string
backq
=
getBackupQuery
WithoutSalt
(
*
schema
,
res
,
db
,
tabl
e
);
std
::
string
backq
=
getBackupQuery
(
*
schema
,
res
,
db
,
table
,
useHex
,
fals
e
);
cout
<<
backq
<<
endl
;
cout
<<
backq
<<
endl
;
//rawReturnValue resraw = executeAndGetResultRemote(globalConn,backq);
timer
t
;
//getInsertQuery(*schema,res,db,table,resraw);
rawReturnValue
resraw
=
executeAndGetResultRemote
(
globalConn
,
backq
);
fprintf
(
stream
,
"3: time to get rows : %.4lf
\n
"
,
t
.
lap
()
*
1.0
/
1000000
);
getInsertQuery
(
*
schema
,
res
,
db
,
table
,
resraw
);
fprintf
(
stream
,
"3: time to sync inserts : %.4lf
\n
"
,
t
.
lap
()
*
1.0
/
1000000
);
}
else
if
(
string
(
argv
[
3
])
==
"4"
){
}
else
if
(
string
(
argv
[
3
])
==
"4"
){
std
::
string
db
(
argv
[
1
]),
table
(
argv
[
2
]);
std
::
string
db
(
argv
[
1
]),
table
(
argv
[
2
]);
std
::
cout
<<
db
<<
":"
<<
table
<<
std
::
endl
;
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
std
::
unique_ptr
<
SchemaInfo
>
schema
=
myLoadSchemaInfo
();
//get all the fields in the tables.
//get all the fields in the tables.
std
::
vector
<
FieldMeta
*>
fms
=
getFieldMeta
(
*
schema
,
db
,
table
);
std
::
vector
<
FieldMeta
*>
fms
=
getFieldMeta
(
*
schema
,
db
,
table
);
...
@@ -826,12 +800,17 @@ main(int argc, char* argv[]) {
...
@@ -826,12 +800,17 @@ main(int argc, char* argv[]) {
assert
(
item
.
onions
.
size
()
==
item
.
originalOm
.
size
());
assert
(
item
.
onions
.
size
()
==
item
.
originalOm
.
size
());
assert
(
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
||
assert
(
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
||
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
+
1
);
item
.
fields
.
size
()
==
item
.
originalOm
.
size
()
+
1
);
item
.
choosenOnions
.
push_back
(
0
);
for
(
unsigned
int
i
=
0u
;
i
<
item
.
onions
.
size
();
i
++
)
{
item
.
choosenOnions
.
push_back
(
i
);
}
}
}
std
::
string
backq
=
getBackupQuery
WithoutSaltHex
(
*
schema
,
res
,
db
,
tabl
e
);
std
::
string
backq
=
getBackupQuery
(
*
schema
,
res
,
db
,
table
,
useHex
,
tru
e
);
cout
<<
backq
<<
endl
;
cout
<<
backq
<<
endl
;
//rawReturnValue resraw = executeAndGetResultRemote(globalConn,backq);
rawReturnValue
resraw
=
executeAndGetResultRemote
(
globalConn
,
backq
);
//getInsertQuery(*schema,res,db,table,resraw);
writeResultsColumns
(
resraw
);
}
else
{
}
}
fclose
(
stream
);
return
0
;
return
0
;
}
}
packages/tls/intnormal.sh
0 → 100755
View file @
ad309c86
if
[
$#
=
0
]
;
then
echo
"arg1 num in pipe, arg2 num of pipe"
exit
fi
function
inittable
{
mysql
-uroot
-pletmein
-h127
.0.0.1
-e
"drop database if exists tpcc1000"
mysql
-uroot
-pletmein
-h127
.0.0.1
-e
"create database tpcc1000"
mysql
-uroot
-pletmein
-h127
.0.0.1
-e
"use tpcc1000; drop table if exists student"
len
=
$[$1
+16]
#not supported
mysql
-uroot
-pletmein
-h127
.0.0.1
-e
"use tpcc1000; create table if not exists student2(name integer)"
}
#generate load.sql
head
=
'INSERT INTO student2 VALUES '
cur
=
1234567
multi
=
""
function
getMultipleFields
{
num
=
$1
multi
=
\(
$cur
\)
for
((
i
=
1
;
i<
$num
;
i++
))
do
multi
=
${
multi
}
\,\(
$cur
\)
done
}
getMultipleFields
$1
rm
-rf
load.sql
echo
"start to get multiple inserts!!!!"
for
((
i
=
0
;
i<
$2
;
i++
))
do
echo
$head$multi
\;
>>
load.sql
done
inittable
mysql
-uroot
-pletmein
-h127
.0.0.1 tpcc1000 < load.sql
mysqldump
--skip-extended-insert
-uroot
-pletmein
-h127
.0.0.1
--hex-blob
--compact
tpcc1000
>
back.sql
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