line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Gnats::Command::CHDB; |
2
|
40
|
|
|
40
|
|
176
|
use parent 'Net::Gnats::Command'; |
|
40
|
|
|
|
|
49
|
|
|
40
|
|
|
|
|
177
|
|
3
|
40
|
|
|
40
|
|
2045
|
use strictures; |
|
40
|
|
|
|
|
51
|
|
|
40
|
|
|
|
|
157
|
|
4
|
|
|
|
|
|
|
BEGIN { |
5
|
40
|
|
|
40
|
|
2926
|
$Net::Gnats::Command::CHDB::VERSION = '0.20'; |
6
|
|
|
|
|
|
|
} |
7
|
40
|
|
|
40
|
|
174
|
use vars qw($VERSION); |
|
40
|
|
|
|
|
47
|
|
|
40
|
|
|
|
|
1519
|
|
8
|
|
|
|
|
|
|
|
9
|
40
|
|
|
40
|
|
176
|
use Net::Gnats::Constants qw(CODE_OK CODE_NO_ACCESS CODE_INVALID_DATABASE); |
|
40
|
|
|
|
|
49
|
|
|
40
|
|
|
|
|
8385
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Net::Gnats::Command::CHDB |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Switches the current database to the name specified in the command. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 PROTOCOL |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
CHDB [database] |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 RESPONSES |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
The possible responses are: |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
422 (CODE_NO_ACCESS) |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
The user does not have permission to access the requested database. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
417 (CODE_INVALID_DATABASE) |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
The database specified does not exist, or one or more configuration |
34
|
|
|
|
|
|
|
errors in the database were encountered. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
210 (CODE_OK) |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
The current database is now database. Any operations performed will |
39
|
|
|
|
|
|
|
now be applied to database. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $c = 'CHDB'; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new { |
46
|
2
|
|
|
2
|
1
|
4
|
my ( $class, %options ) = @_; |
47
|
2
|
|
|
|
|
4
|
my $self = bless \%options, $class; |
48
|
2
|
|
|
|
|
4
|
return $self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub as_string { |
52
|
3
|
|
|
3
|
1
|
4
|
my ($self) = @_; |
53
|
3
|
100
|
|
|
|
14
|
return undef if not defined $self->{database}; |
54
|
2
|
|
|
|
|
9
|
return $c . ' ' . $self->{database}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub is_ok { |
58
|
2
|
|
|
2
|
0
|
3
|
my ($self) = @_; |
59
|
|
|
|
|
|
|
# command not issued yet |
60
|
2
|
100
|
|
|
|
7
|
return 0 if not defined $self->response; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# command received malformed response |
63
|
1
|
50
|
|
|
|
2
|
return 0 if not defined $self->response->code; |
64
|
1
|
50
|
|
|
|
2
|
return 1 if $self->response->code == CODE_OK; |
65
|
0
|
|
|
|
|
|
return 0; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |