mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-22 14:07:55 +00:00
sql: fixed bug #34034: sql: --list-databases
This commit is contained in:
parent
986f69db11
commit
b511c409ad
41
src/sql
41
src/sql
|
@ -82,13 +82,24 @@ HTML output. Turn on HTML tabular output.
|
|||
Show the list of running queries.
|
||||
|
||||
|
||||
=item B<--show-databases>
|
||||
|
||||
=item B<--showdbs>
|
||||
|
||||
=item B<--list-databases>
|
||||
|
||||
=item B<--listdbs>
|
||||
|
||||
List the databases (table spaces) in the database.
|
||||
|
||||
|
||||
=item B<--show-tables>
|
||||
|
||||
=item B<--list-tables>
|
||||
|
||||
=item B<--table-list>
|
||||
|
||||
List the tables in the database
|
||||
List the tables in the database.
|
||||
|
||||
|
||||
=item B<--noheaders>
|
||||
|
@ -493,6 +504,10 @@ if(defined $::opt_tablelist) {
|
|||
unshift @ARGV, tablelist($database_driver,%dburl);
|
||||
}
|
||||
|
||||
if(defined $::opt_dblist) {
|
||||
unshift @ARGV, dblist($database_driver,%dburl);
|
||||
}
|
||||
|
||||
if(defined $::opt_dbsize) {
|
||||
unshift @ARGV, dbsize($database_driver,%dburl);
|
||||
}
|
||||
|
@ -556,6 +571,11 @@ sub parse_options {
|
|||
"show-processlist|proclist|listproc" => \$::opt_processlist,
|
||||
"show-tables|showtables|listtables|list-tables|tablelist|table-list"
|
||||
=> \$::opt_tablelist,
|
||||
"dblist|".
|
||||
"listdb|listdbs|list-db|list-dbs|list-database|".
|
||||
"list-databases|listdatabases|listdatabase|showdb|".
|
||||
"showdbs|show-db|show-dbs|show-database|show-databases|".
|
||||
"showdatabases|showdatabase" => \$::opt_dblist,
|
||||
"db-size|dbsize" => \$::opt_dbsize,
|
||||
"table-size|tablesize" => \$::opt_tablesize,
|
||||
"noheaders|no-headers|n" => \$::opt_n,
|
||||
|
@ -767,6 +787,25 @@ sub tablelist {
|
|||
}
|
||||
}
|
||||
|
||||
# Return the code for 'show databases' in the chosen database dialect
|
||||
sub dblist {
|
||||
my $dbdriver = shift;
|
||||
my %dburl = @_;
|
||||
my %statement =
|
||||
("mysql" => "show databases;",
|
||||
"postgresql" => ("SELECT datname FROM pg_database ".
|
||||
"WHERE datname NOT IN ('template0','template1','postgres') ".
|
||||
"ORDER BY datname ASC;"),
|
||||
"oracle" => ("select * from user_tablespaces;"),
|
||||
);
|
||||
if($statement{$dbdriver}) {
|
||||
return $statement{$dbdriver};
|
||||
} else {
|
||||
print STDERR "dblist is not implemented for $dbdriver\n";
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
|
||||
# Return the code for 'show database size' in the chosen database dialect
|
||||
sub dbsize {
|
||||
my $dbdriver = shift;
|
||||
|
|
Loading…
Reference in a new issue