sql --dbsize will now list sizes of all databases if given no database.

This commit is contained in:
Ole Tange 2012-04-21 20:16:59 +02:00
parent 463ec5bc0b
commit afbbc30ce6
4 changed files with 91 additions and 25 deletions

34
NEWS
View file

@ -1,3 +1,37 @@
20120422
* A race condition bug caused restructuring of a central piece of the
code. Thus this release of GNU Parallel should be considered beta
quality.
* sql --dbsize will now list sizes of all databases if given no
database.
* Article: Computational and experimental analyses of
retrotransposon-associated minisatellite DNAs in the soybean genome.
http://www.biomedcentral.com/content/supplementary/1471-2105-13-s2-s13-s1.pdf
* Blog post: GNU parallel - the best thing since sliced bread.
https://arrayal.wordpress.com/2012/03/27/gnu-parallel-the-best-thing-since-sliced-bread/
* Blog post: GNU Parallel makes everything faster.
http://compbiously.blogspot.com/2012/03/gnu-parallel-makes-everything-faster.html
* Blog post (German): Howto: GNU parallel.
http://d24m.de/2012/04/05/howto-gnu-parallel/
* Blog post: Running in Parallel
http://interactivity.ifactory.com/2012/04/running-in-parallel/
* 20000 watched the first intro video.
http://pi.dk/1
* The first 5 have received their GNU Parallel merchandise
https://www.gnu.org/software/parallel/merchandise.html
* Bug fixes and man page updates.
20120322
* Parallel Process Database Dumps.

View file

@ -171,16 +171,20 @@ cc:Sandro Cazzaniga <kharec@mandriva.org>,
Ryoichiro Suzuki <ryoichiro.suzuki@gmail.com>,
Jesse Alama <jesse.alama@gmail.com>
Subject: GNU Parallel 20120422 ('') released
Subject: GNU Parallel 20120422 ('Mærsk') released
GNU Parallel 20120422 ('') has been released. It is
GNU Parallel 20120422 ('Mærsk') has been released. It is
available for download at: http://ftp.gnu.org/gnu/parallel/
This is a bugfix release with no new features. Probably a good release
for stable long-term use.
New in this release:
* A race condition bug caused restructuring of a central piece of the
code. Thus this release of GNU Parallel should be considered beta
quality.
* sql --dbsize will now list sizes of all databases if given no
database.
* Article: Computational and experimental analyses of
retrotransposon-associated minisatellite DNAs in the soybean genome.
http://www.biomedcentral.com/content/supplementary/1471-2105-13-s2-s13-s1.pdf
@ -197,6 +201,12 @@ New in this release:
* Blog post: Running in Parallel
http://interactivity.ifactory.com/2012/04/running-in-parallel/
* 20000 watched the first intro video.
http://pi.dk/1
* The first 5 have received their GNU Parallel merchandise
https://www.gnu.org/software/parallel/merchandise.html
* Bug fixes and man page updates.

View file

@ -1334,9 +1334,9 @@ Use B<-v> B<-v> to print the wrapping ssh command when running remotely.
Print the version GNU B<parallel> and exit.
=item B<--workdir> I<mydir> (beta testing)
=item B<--workdir> I<mydir>
=item B<--wd> I<mydir> (beta testing)
=item B<--wd> I<mydir>
Files transferred using B<--transfer> and B<--return> will be relative
to I<mydir> on remote computers, and the command will be executed in

58
src/sql
View file

@ -815,22 +815,45 @@ sub dblist {
sub dbsize {
my $dbdriver = shift;
my %dburl = @_;
my %statement =
("mysql" => (
'SELECT '.
' table_schema "Data Base Name", '.
' SUM(data_length+index_length)/1024/1024 "Data Base Size in MB" '.
'FROM information_schema.TABLES '.
'GROUP BY table_schema;'),
"postgresql" => (
"SELECT ".
" pg_database_size('".$dburl{'database'}."') AS bytes,".
" pg_size_pretty(pg_database_size('".$dburl{'database'}."')) AS human_readable;"),
"sqlite" => (
"SELECT ".(undef_as_zero(-s $dburl{'database'}))." AS bytes;"),
"sqlite3" => (
"SELECT ".(undef_as_zero(-s $dburl{'database'}))." AS bytes;"),
);
my %statement;
if(defined $dburl{'database'}) {
%statement =
("mysql" => (
'SELECT '.
' table_schema "database", '.
' SUM(data_length+index_length) "bytes", '.
' SUM(data_length+index_length)/1024/1024 "megabytes" '.
'FROM information_schema.TABLES '.
"WHERE table_schema = '$dburl{'database'}'".
'GROUP BY table_schema;'),
"postgresql" => (
"SELECT '$dburl{'database'}' AS database, ".
"pg_database_size('$dburl{'database'}') AS bytes, ".
"pg_size_pretty(pg_database_size('$dburl{'database'}')) AS human_readabable "),
"sqlite" => (
"SELECT ".(undef_as_zero(-s $dburl{'database'}))." AS bytes;"),
"sqlite3" => (
"SELECT ".(undef_as_zero(-s $dburl{'database'}))." AS bytes;"),
);
} else {
%statement =
("mysql" => (
'SELECT '.
' table_schema "database", '.
' SUM(data_length+index_length) "bytes", '.
' SUM(data_length+index_length)/1024/1024 "megabytes" '.
'FROM information_schema.TABLES '.
'GROUP BY table_schema;'),
"postgresql" => (
'SELECT datname AS database, pg_database_size(datname) AS bytes, '.
'pg_size_pretty(pg_database_size(datname)) AS human_readabable '.
'FROM (SELECT datname FROM pg_database) a;'),
"sqlite" => (
"SELECT 0 AS bytes;"),
"sqlite3" => (
"SELECT 0 AS bytes;"),
);
}
if($statement{$dbdriver}) {
return $statement{$dbdriver};
} else {
@ -840,7 +863,7 @@ sub dbsize {
}
# Return the code for 'show database size' in the chosen database dialect
# Return the code for 'show table size' in the chosen database dialect
sub tablesize {
my $dbdriver = shift;
my $database = shift;
@ -1070,5 +1093,4 @@ sub debug {
print @_;
}
# TODO --list-databases: psql -l eller '\l'. mysql show databases. Oracle ?
$::opt_skip_first_line = $::opt_shebang = 0;