diff --git a/database/postgres/mode/databasesize.pm b/database/postgres/mode/databasesize.pm index 56639706d..be8fdf740 100644 --- a/database/postgres/mode/databasesize.pm +++ b/database/postgres/mode/databasesize.pm @@ -79,6 +79,8 @@ sub manage_selection { my $result = $self->{sql}->fetchall_arrayref(); + $self->{databases} = {}; + foreach my $row (@$result) { next if (defined($self->{option_results}->{filter_database}) && $self->{option_results}->{filter_database} ne '' && $$row[0] !~ /$self->{option_results}->{filter_database}/); @@ -86,6 +88,11 @@ sub manage_selection { $self->{databases}->{$$row[0]}->{display} = $$row[0]; $self->{databases}->{$$row[0]}->{size} = $$row[1]; } + + if (scalar(keys %{$self->{databases}}) <= 0) { + $self->{output}->add_option_msg(short_msg => 'No databases found'); + $self->{output}->option_exit(); + } } 1;