dbMan/Extension/CmdSetOracleSpecials.pm untested

filter: Statementstmt 0.0% 0 / 45 Branchbran 0.0% 0 / 24 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 83 CC 13 SCAR 37.4
CC
13
Cov
0%
cmdcomplete
72.0
handle_action
42.0
IDENTIFICATION
2.0
CRAP 42.0
1 package DBIx::dbMan::Extension::CmdSetOracleSpecials;
2  
3 use strict;
4 use base 'DBIx::dbMan::Extension';
5  
6 our $VERSION = '0.02';
7  
8 1;
9  
10 sub IDENTIFICATION { return "000001-000099-000002"; }
11  
12 sub preference { return 1000; }
13  
14 sub known_actions { return [ qw/COMMAND/ ]; }
15  
16 sub handle_action {
17 my ($obj,%action) = @_;
18  
19 if ($action{action} eq 'COMMAND') {
20 if ($action{cmd} =~ /^set\s+oracle\s+xplan\s+(on|off)$/i) {
21 my $want = lc $1; my $owant = $want;
22 $want = ($want eq 'off')?0:1;
23 $action{action} = 'OUTPUT';
24  
25 my $local_mempool = $obj->{-dbi}->mempool();
26 if ( $local_mempool ) {
27 $local_mempool->set( 'oracle_special_xplan', $want );
28 $action{output} = "Oracle DBMS_XPLAN module support $owant.\n";
29 } else {
30 $action{output} = "There is no active connection where DBMS_XPLAN module can be used.\n";
31 }
32  
33 $obj->{-interface}->rebuild_menu();
34 } elsif ($action{cmd} =~ /^set\s+oracle\s+longreadlen\s+to\s+(\d+)\s*$/i) {
35 my $lrl_to = $1;
36 $action{action} = 'OUTPUT';
37 my $lrl_from = $obj->{-dbi}->longreadlen();
38 $obj->{-dbi}->longreadlen($lrl_to);
39 $action{output} = "Oracle LongReadLen changed from $lrl_from to $lrl_to.\n";
40 }
41 }
42  
43 $action{processed} = 1;
44 return %action;
45 }
46  
47 sub cmdhelp {
48 return [
49 'SET ORACLE XPLAN [ON|OFF]' => 'Set Oracle DBMS_XPLAN module on or off (for db version 10 or newer).',
50 'SET ORACLE LONGREADLEN TO <number>' => 'Set Oracle LongReadLen connection parameter to selected value.'
51 ];
52 }
53  
54 sub cmdcomplete {
55 my ($obj,$text,$line,$start) = @_;
56  
57 my $local_mempool = $obj->{-dbi}->mempool();
58 return qw/ORACLE/ if $line =~ /^\s*SET\s+\S*$/i;
59 return qw/SET/ if $line =~ /^\s*[A-Z]*$/i;
60  
61 my @ret = ();
62 if ( $local_mempool ) {
63 push @ret, qw/ON OFF/ if $line =~ /^\s*SET\s+ORACLE\s+XPLAN\s+\S*$/i;
64 push @ret, qw/XPLAN/ if $line =~ /^\s*SET\s+ORACLE\s+\S*$/i;
65 }
66 push @ret, qw/LONGREADLEN/ if $line =~ /^\s*SET\s+ORACLE\s+\S*$/i;
67 push @ret, qw/TO/ if $line =~ /^\s*SET\s+ORACLE\s+LONGREADLEN\s+\S*$/i;
68  
69 return @ret;
70 }