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
e1dd2134
Commit
e1dd2134
authored
Jun 11, 2017
by
Casualet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add count.sh
parent
32bba12d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
14 deletions
+42
-14
cdb_test.cc
main/cdb_test.cc
+3
-3
backFieldsToFiles
packages/tls/mysqlWrapper/backFieldsToFiles
+0
-0
backFieldsToFiles.cc
packages/tls/mysqlWrapper/backFieldsToFiles.cc
+10
-9
count.sh
packages/tls/shell/count.sh
+28
-0
util.cc
util/util.cc
+1
-2
No files found.
main/cdb_test.cc
View file @
e1dd2134
...
...
@@ -297,7 +297,7 @@ void myNext(std::string client,bool isFirst,ResType inRes) {
switch
(
result_type
){
//execute the query, fetch the results, and call next again
case
AbstractQueryExecutor
:
:
ResultType
::
QUERY_COME_AGAIN
:
{
//
std::cout<<RED_BEGIN<<"case one"<<COLOR_END<<std::endl;
std
::
cout
<<
RED_BEGIN
<<
"case one"
<<
COLOR_END
<<
std
::
endl
;
const
auto
&
output
=
std
::
get
<
1
>
(
new_results
)
->
extract
<
std
::
pair
<
bool
,
std
::
string
>
>
();
const
auto
&
next_query
=
output
.
second
;
...
...
@@ -311,7 +311,7 @@ void myNext(std::string client,bool isFirst,ResType inRes) {
//only execute the query, without processing the retults
case
AbstractQueryExecutor
:
:
ResultType
::
QUERY_USE_RESULTS
:
{
//
std::cout<<RED_BEGIN<<"case two"<<COLOR_END<<std::endl;
std
::
cout
<<
RED_BEGIN
<<
"case two"
<<
COLOR_END
<<
std
::
endl
;
const
auto
&
new_query
=
std
::
get
<
1
>
(
new_results
)
->
extract
<
std
::
string
>
();
auto
resRemote
=
executeAndGetResultRemote
(
globalConn
,
new_query
);
...
...
@@ -321,7 +321,7 @@ void myNext(std::string client,bool isFirst,ResType inRes) {
//return the results to the client directly
case
AbstractQueryExecutor
:
:
ResultType
::
RESULTS
:
{
//
std::cout<<RED_BEGIN<<"case three"<<COLOR_END<<std::endl;
std
::
cout
<<
RED_BEGIN
<<
"case three"
<<
COLOR_END
<<
std
::
endl
;
const
auto
&
res
=
new_results
.
second
->
extract
<
ResType
>
();
parseResType
(
res
);
break
;
...
...
packages/tls/mysqlWrapper/backFieldsToFiles
0 → 100755
View file @
e1dd2134
File added
packages/tls/mysqlWrapper/backFieldsToFiles.cc
View file @
e1dd2134
...
...
@@ -7,7 +7,7 @@
using
namespace
std
;
extern
Connect
*
con
;
string
createSelect
(
string
database
,
string
table
,
bool
isQuote
=
tru
e
){
string
createSelect
(
string
database
,
string
table
,
int
quot
e
){
auto
dbresult
=
con
->
execute
(
string
(
"SELECT * FROM `"
)
+
database
+
"`.`"
+
string
(
table
)
+
"` LIMIT 1;"
);
DBResult
*
result
=
dbresult
.
get
();
vector
<
vector
<
string
>>
rows
=
result
->
getRows
();
...
...
@@ -17,11 +17,11 @@ string createSelect(string database,string table,bool isQuote=true){
for
(
int
i
=
0
;
i
<
types
.
size
();
i
++
){
if
(
IS_NUM
(
types
[
i
])){
head
+=
fields
[
i
]
+
","
;
}
else
{
if
(
isQuote
)
}
else
{
if
(
quote
==
1
)
head
+=
string
(
"QUOTE("
)
+
fields
[
i
]
+
") AS quo"
+
fields
[
i
]
+
" ,"
;
else
head
+=
string
(
"HEX("
)
+
fields
[
i
]
+
") AS hex"
+
fields
[
i
]
+
" ,"
;
else
if
(
quote
==
2
)
head
+=
string
(
"HEX("
)
+
fields
[
i
]
+
") AS hex"
+
fields
[
i
]
+
" ,"
;
else
if
(
quote
==
3
)
head
+=
fields
[
i
]
+
","
;
}
}
head
[
head
.
size
()
-
1
]
=
' '
;
...
...
@@ -72,16 +72,17 @@ vector<string> getTables(string db){
int
main
(
int
argc
,
char
**
argv
){
system
(
"rm -rf allTables"
);
system
(
"mkdir allTables"
);
if
(
argc
!=
2
){
cout
<<
"db"
<<
endl
;
if
(
argc
!=
3
){
cout
<<
"db
, 1quote/2hex/3plain
"
<<
endl
;
return
0
;
}
string
option
(
argv
[
2
]);
string
num
=
string
(
argv
[
1
]);
vector
<
string
>
tablesprefix
=
getTables
(
string
(
argv
[
1
]));
for
(
auto
item
:
tablesprefix
){
string
query
=
createSelect
(
string
(
argv
[
1
]),
item
);
string
query
=
createSelect
(
string
(
argv
[
1
]),
item
,
stoi
(
option
)
);
backupselect
(
query
,
string
(
"allTables/"
)
+
item
+
"/"
);
}
return
0
;
...
...
packages/tls/shell/count.sh
0 → 100755
View file @
e1dd2134
## specify the database name, and get the total count of all the tables in that database
function
mysql_command
(){
cmd
=
\'
$1
\'
#single quoted ${cmd} is not recognised
final
=
"mysql -uroot -pletmein -h127.0.0.1 -e
${
cmd
}
"
#eval can not be ommited here, can not just use $final only for this command
res
=
`
eval
$final
`
echo
$res
}
function
show_table_counts
(){
db
=
$1
raw
=
`
mysql
-uroot
-pletmein
-h127
.0.0.1
-e
"use
$db
;show tables;"
|
awk
'{print $1}'
`
arr
=(
$raw
)
len
=
${#
arr
[@]
}
for
((
i
=
1
;
i<
$len
;
i++
))
do
res
=
`
mysql_command
"SELECT COUNT(*) AS total_count FROM
$1
.
${
arr
[
$i
]
}
"
`
echo
${
arr
[
$i
]
}
,
$res
done
}
show_table_counts
$1
#res=`mysql_command 'show databases'`
#echo $res
##only support numeric return value
#echo $?
util/util.cc
View file @
e1dd2134
...
...
@@ -108,8 +108,7 @@ IntFromBytes(const unsigned char * bytes, unsigned int noBytes)
}
uint64_t
uint64FromZZ
(
ZZ
val
)
{
uint64FromZZ
(
ZZ
val
){
uint64_t
res
=
0
;
uint64_t
mul
=
1
;
while
(
val
>
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