| 1 | package PMLTQ::Command::delete; | ||||||||||
| 2 | 1 | our $AUTHORITY = 'cpan:MATY'; | |||||||||
| 3 | 1 | $PMLTQ::Command::delete::VERSION = '2.0.3'; | |||||||||
| 4 | # ABSTRACT: Deletes the treebank from database | ||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use PMLTQ::Base 'PMLTQ::Command'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 0 | ▶ | has usage => sub { shift->extract_usage }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 9 | |||||||||||
| 10 | 0 | ▶ | sub run { | ||||||||
|
Subroutine
run: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 11 | 0 | my $self = shift; | |||||||||
| 12 | 0 | my $config = $self->config; | |||||||||
| 13 | |||||||||||
| 14 | 0 | my $dbh = $self->sys_db; | |||||||||
| 15 | 0 | $dbh->do("SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$config->{db}->{name}' AND pid <> pg_backend_pid();"); # disconnect all connections to deleted database | |||||||||
| 16 | 0 | $dbh->do("DROP DATABASE \"$config->{db}->{name}\";"); | |||||||||
| 17 | 0 | my $error = $dbh->errstr; | |||||||||
| 18 | 0 | $dbh->disconnect; | |||||||||
| 19 | 0 | ▶ | die $error if $error; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | =head1 SYNOPSIS | ||||||||||
| 23 | |||||||||||
| 24 | pmltq delete <treebank_config> | ||||||||||
| 25 | |||||||||||
| 26 | =head1 DESCRIPTION | ||||||||||
| 27 | |||||||||||
| 28 | Delete the treebank from database. | ||||||||||
| 29 | |||||||||||
| 30 | =head1 OPTIONS | ||||||||||
| 31 | |||||||||||
| 32 | =head1 PARAMS | ||||||||||
| 33 | |||||||||||
| 34 | =over 5 | ||||||||||
| 35 | |||||||||||
| 36 | =item B<treebank_config> | ||||||||||
| 37 | |||||||||||
| 38 | Path to configuration file. If a treebank_config is --, config is readed from STDIN. | ||||||||||
| 39 | |||||||||||
| 40 | =back | ||||||||||
| 41 | |||||||||||
| 42 | =cut | ||||||||||
| 43 | |||||||||||
| 44 | 1 | 1; | |||||||||