File Coverage

blib/lib/DBD/Simulated/dr.pm
Criterion Covered Total %
statement 9 20 45.0
branch 0 6 0.0
condition n/a
subroutine 3 5 60.0
pod 0 2 0.0
total 12 33 36.3


line stmt bran cond sub pod time code
1             package DBD::Simulated::dr;
2              
3             =pod
4              
5             =head1 NAME
6              
7             DBD::Simulated::dr - Driver part for DBD::Simulated
8              
9             =head1 SYNOPSIS
10              
11             Do not use this directly without DBI. See L for more information about using a DBD module.
12              
13             =head1 DESCRIPTION
14              
15             see L.
16              
17             =cut
18              
19 1     1   18 use 5.010;
  1         3  
  1         49  
20 1     1   5 use strict;
  1         2  
  1         25  
21 1     1   5 use warnings;
  1         1  
  1         462  
22              
23             our $VERSION = '0.01';
24              
25             $DBD::Simulated::dr::imp_data_size = 0;
26              
27             sub connect {
28 0     0 0   my ($drh, $dr_dsn, $user, $auth, $attr) = @_;
29              
30 0           my $driver_prefix = "simulated_"; # the assigned prefix for this driver
31              
32             # Process attributes from the DSN; we assume ODBC syntax
33             # here, that is, the DSN looks like var1=val1;...;varN=valN
34 0           foreach my $var (split /;/, $dr_dsn) {
35 0           my ($attr_name, $attr_value) = split /=/, $var, 2;
36 0 0         return $drh->set_err($DBI::stderr, "Can't parse DSN part '$var'")
37             unless defined $attr_value;
38              
39             # add driver prefix to attribute name if it doesn't have it already
40 0 0         next unless $attr_name =~ /^$driver_prefix/o;
41              
42             # Store attribute into %$attr, replacing any existing value.
43             # The DBI will STORE() these into $dbh after we've connected
44 0           $attr->{$attr_name} = $attr_value;
45             }
46              
47             # Simulated connect error
48 0 0         return $drh->set_err($attr->{simulated_error}, 'Simulated error #' . $attr->{simulated_error})
49             if $attr->{simulated_error};
50              
51             # create a 'blank' dbh (call superclass constructor)
52 0           my ($outer, $dbh) = DBI::_new_dbh($drh, {Name => $dr_dsn});
53              
54             # STORE = visible within the "public" $dbh returned by DBI->connect
55             # $dbh->STORE('Active', 1 );
56             # $dbh->{drv_connection} = $connection;
57              
58 0           return $outer;
59             }
60              
61             sub data_sources {
62 0     0 0   return 'dbi:simulated:simulated_error';
63             }
64              
65             1;
66              
67             =pod
68              
69             =head1 SUPPORT
70              
71             No support is available
72              
73             =head1 AUTHOR
74              
75             Copyright 2012 Sebastian Willing, eGENTIC Systems L
76              
77             =cut