line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Gnats::Command::CHDB; |
2
|
40
|
|
|
40
|
|
202
|
use parent 'Net::Gnats::Command'; |
|
40
|
|
|
|
|
55
|
|
|
40
|
|
|
|
|
193
|
|
3
|
40
|
|
|
40
|
|
2248
|
use strictures; |
|
40
|
|
|
|
|
60
|
|
|
40
|
|
|
|
|
193
|
|
4
|
|
|
|
|
|
|
BEGIN { |
5
|
40
|
|
|
40
|
|
3305
|
$Net::Gnats::Command::CHDB::VERSION = '0.21'; |
6
|
|
|
|
|
|
|
} |
7
|
40
|
|
|
40
|
|
202
|
use vars qw($VERSION); |
|
40
|
|
|
|
|
60
|
|
|
40
|
|
|
|
|
1929
|
|
8
|
|
|
|
|
|
|
|
9
|
40
|
|
|
40
|
|
235
|
use Net::Gnats::Constants qw(CODE_OK CODE_NO_ACCESS CODE_INVALID_DATABASE); |
|
40
|
|
|
|
|
56
|
|
|
40
|
|
|
|
|
9296
|
|
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
|
|
|
|
|
5
|
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
|
|
|
|
19
|
return undef if not defined $self->{database}; |
54
|
2
|
|
|
|
|
8
|
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
|
|
|
|
8
|
return 0 if not defined $self->response; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# command received malformed response |
63
|
1
|
50
|
|
|
|
4
|
return 0 if not defined $self->response->code; |
64
|
1
|
50
|
|
|
|
4
|
return 1 if $self->response->code == CODE_OK; |
65
|
0
|
|
|
|
|
|
return 0; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |