| 1 | package Dancer::Plugin::Database::Core; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | Dancer::Plugin::Database::Core - Shared core for D1 and D2 Database plugins | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | Version 0.08 | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | our $VERSION = '0.08_03'; | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | my %handles; | |||||||||||||||||||||||||||||||||||||||||
| 20 | # Hashref used as key for default handle, so we don't have a magic value that | ||||||||||||||||||||||||||||||||||||||||||
| 21 | # the user could use for one of their connection names and cause problems | ||||||||||||||||||||||||||||||||||||||||||
| 22 | # (Kudos to Igor Bujna for the idea) | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | my $def_handle = {}; | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | This module should not be used directly. It is a shared library for | ||||||||||||||||||||||||||||||||||||||||||
| 28 | L<Dancer::Plugin::Database> and L<Dancer2::Plugin::Database> modules. | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | =head2 database | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | Implements the C<database> keyword. | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | sub database { | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | my %args = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
database: not called CC=21 SCAR=61.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | my $arg = $args{arg} || undef; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'arg'} || undef
MC/DC0%0/1
$args{'arg'} || undef
$args{'arg'}
Truth table0%0/2
A
A= $args{'arg'}
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $settings = $args{settings} || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'settings'} || {}
MC/DC0%0/1
$args{'settings'} || {}
$args{'settings'}
Truth table0%0/2
A
A= $args{'settings'}
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | my $logger = $args{logger} || sub {}; ## die? | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$args{'logger'} || sub {
}
MC/DC0%0/2
$args{'logger'} || sub {
}
$args{'logger'}
sub {
}
Truth table0%0/3
A || B
A= $args{'logger'}B= sub {
}
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | my $hook_exec = $args{hook_exec} || sub {}; ## die? | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$args{'hook_exec'} || sub {
}
MC/DC0%0/2
$args{'hook_exec'} || sub {
}
$args{'hook_exec'}
sub {
}
Truth table0%0/3
A || B
A= $args{'hook_exec'}B= sub {
}
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | # The key to use to store this handle in %handles. This will be either the | ||||||||||||||||||||||||||||||||||||||||||
| 46 | # name supplied to database(), the hashref supplied to database() (thus, as | ||||||||||||||||||||||||||||||||||||||||||
| 47 | # long as the same hashref of settings is passed, the same handle will be | ||||||||||||||||||||||||||||||||||||||||||
| 48 | # reused) or $def_handle if database() is called without args: | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my $handle_key; | |||||||||||||||||||||||||||||||||||||||||
| 50 | my $conn_details; # connection settings to use. | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | my $handle; | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | # Accept a hashref of settings to use, if desired. If so, we use this | ||||||||||||||||||||||||||||||||||||||||||
| 54 | # hashref to look for the handle, too, so as long as the same hashref is | ||||||||||||||||||||||||||||||||||||||||||
| 55 | # passed to the database() keyword, we'll reuse the same handle: | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if (ref $arg eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $handle_key = $arg; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $conn_details = $arg; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | $handle_key = defined $arg ? $arg : $def_handle; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | $conn_details = _get_settings($arg, $settings, $logger); | |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if (!$conn_details) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | $logger->(error => "No DB settings for " . ($arg || "default connection")); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$arg || 'default connection'
MC/DC0%0/1
$arg || 'default connection'
$arg
Truth table0%0/2
A
A= $arg
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | return (undef, $settings); | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | # To be fork safe and thread safe, use a combination of the PID and TID (if | ||||||||||||||||||||||||||||||||||||||||||
| 69 | # running with use threads) to make sure no two processes/threads share | ||||||||||||||||||||||||||||||||||||||||||
| 70 | # handles. Implementation based on DBIx::Connector by David E. Wheeler. | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $pid_tid = $$; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | $pid_tid .= '_' . threads->tid if $INC{'threads.pm'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | # OK, see if we have a matching handle | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | $handle = $handles{$pid_tid}{$handle_key} || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$handles{$pid_tid}{$handle_key} || {}
MC/DC0%0/1
$handles{$pid_tid}{$handle_key} || {}
$handles{$pid_tid}{$handle_key}
Truth table0%0/2
A
A= $handles{$pid_tid}{$handle_key}
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if ($handle->{dbh}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | # If we should never check, go no further: | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | if (!$conn_details->{connection_check_threshold}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | return ($handle->{dbh}, $settings); | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | if ($handle->{dbh}{Active} && $conn_details->{connection_check_threshold} && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$handle->{"dbh"}{"Active"} and $conn_details->{"connection_check_threshold"} and time - $handle->{"last_connection_check"} < $conn_details->{"connection_check_threshold"}
$handle->{"dbh"}{"Active"} and $conn_details->{"connection_check_threshold"}
MC/DC0%0/3
$handle->{"dbh"}{"Active"} and $conn_details->{"connection_check_threshold"} and time - $handle->{"last_connection_check"} < $conn_details->{"connection_check_threshold"}
$handle->{"dbh"}{"Active"}
$conn_details->{"connection_check_threshold"}
time - $handle->{"last_connection_check"} < $conn_details->{"connection_check_threshold"}
Truth table0%0/4
A and B and C
A= $handle->{"dbh"}{"Active"}B= $conn_details->{"connection_check_threshold"}C= time - $handle->{"last_connection_check"} < $conn_details->{"connection_check_threshold"}
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | time - $handle->{last_connection_check} | ||||||||||||||||||||||||||||||||||||||||||
| 85 | < $conn_details->{connection_check_threshold}) | ||||||||||||||||||||||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | return ($handle->{dbh}, $settings); | |||||||||||||||||||||||||||||||||||||||||
| 88 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if (_check_connection($handle->{dbh})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $handle->{last_connection_check} = time; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | return ($handle->{dbh}, $settings); | |||||||||||||||||||||||||||||||||||||||||
| 92 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $logger->(debug => "Database connection went away, reconnecting"); | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $hook_exec->('database_connection_lost', $handle->{dbh}); | |||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if ($handle->{dbh}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | eval { $handle->{dbh}->disconnect } | |||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | # Need a new handle. | ||||||||||||||||||||||||||||||||||||||||||
| 102 | # Fall through to the new connection codepath to get one. | ||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | # Get a new connection | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $handle->{dbh} = _get_connection($conn_details, $logger, $hook_exec); | |||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if ($handle->{dbh}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $handle->{last_connection_check} = time; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $handles{$pid_tid}{$handle_key} = $handle; | |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if (ref $handle_key && ref $handle_key ne ref $def_handle) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $handle_key and ref $handle_key ne ref $def_handle
MC/DC0%0/2
ref $handle_key and ref $handle_key ne ref $def_handle
ref $handle_key
ref $handle_key ne ref $def_handle
Truth table0%0/3
A and B
A= ref $handle_keyB= ref $handle_key ne ref $def_handle
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | # We were given a hashref of connection settings. Shove a | ||||||||||||||||||||||||||||||||||||||||||
| 117 | # reference to that hashref into the handle, so that the hashref | ||||||||||||||||||||||||||||||||||||||||||
| 118 | # doesn't go out of scope for the life of the handle. | ||||||||||||||||||||||||||||||||||||||||||
| 119 | # Otherwise, that area of memory could be re-used, and, given | ||||||||||||||||||||||||||||||||||||||||||
| 120 | # different DB settings in a hashref that just happens to have | ||||||||||||||||||||||||||||||||||||||||||
| 121 | # the same address, we'll happily hand back the original handle. | ||||||||||||||||||||||||||||||||||||||||||
| 122 | # See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=665221 | ||||||||||||||||||||||||||||||||||||||||||
| 123 | # Thanks to Sam Kington for suggesting this fix :) | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $handle->{_orig_settings_hashref} = $handle_key; | |||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | return ($handle->{dbh}, $settings); | |||||||||||||||||||||||||||||||||||||||||
| 128 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | return (undef, $settings); | |||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | sub _get_settings { | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | my ($name, $settings, $logger) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_settings: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $return_settings; | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | # If no name given, just return the default settings | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if (!defined $name) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $return_settings = { %$settings }; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if (!$return_settings->{driver} && !$return_settings->{dsn}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$return_settings->{"driver"} or $return_settings->{"dsn"}
MC/DC0%0/2
$return_settings->{"driver"} or $return_settings->{"dsn"}
$return_settings->{"driver"}
$return_settings->{"dsn"}
Truth table0%0/3
A or B
A= $return_settings->{"driver"}B= $return_settings->{"dsn"}
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $logger->('error', | |||||||||||||||||||||||||||||||||||||||||
| 146 | "Asked for default connection (no name given)" | ||||||||||||||||||||||||||||||||||||||||||
| 147 | ." but no default connection details found in config" | ||||||||||||||||||||||||||||||||||||||||||
| 148 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 151 | # If there are no named connections in the config, bail now: | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | return unless exists $settings->{connections}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | # OK, find a matching config for this name: | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | if (my $named_settings = $settings->{connections}{$name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | # Take a (shallow) copy of the settings, so we don't change them | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $return_settings = { %$named_settings }; | |||||||||||||||||||||||||||||||||||||||||
| 159 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 160 | # OK, didn't match anything | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $logger->('error', | |||||||||||||||||||||||||||||||||||||||||
| 162 | "Asked for a database handle named '$name' but no matching " | ||||||||||||||||||||||||||||||||||||||||||
| 163 | ."connection details found in config" | ||||||||||||||||||||||||||||||||||||||||||
| 164 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | # We should have something to return now; make sure we have a | ||||||||||||||||||||||||||||||||||||||||||
| 169 | # connection_check_threshold, then return what we found. In previous | ||||||||||||||||||||||||||||||||||||||||||
| 170 | # versions the documentation contained a typo mentioning | ||||||||||||||||||||||||||||||||||||||||||
| 171 | # connectivity-check-threshold, so support that as an alias. | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if (exists $return_settings->{'connectivity-check-threshold'} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $return_settings->{"connectivity-check-threshold"} and not exists $return_settings->{"connection_check_threshold"}
MC/DC0%0/2
exists $return_settings->{"connectivity-check-threshold"} and not exists $return_settings->{"connection_check_threshold"}
exists $return_settings->{"connectivity-check-threshold"}
not exists $return_settings->{"connection_check_threshold"}
Truth table0%0/3
A and not(B)
A= exists $return_settings->{"connectivity-check-threshold"}B= not exists $return_settings->{"connection_check_threshold"}
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | && !exists $return_settings->{connection_check_threshold}) | ||||||||||||||||||||||||||||||||||||||||||
| 174 | { | ||||||||||||||||||||||||||||||||||||||||||
| 175 | $return_settings->{connection_check_threshold} | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | = delete $return_settings->{'connectivity-check-threshold'}; | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | # If the setting wasn't provided, default to 30 seconds; if a false value is | ||||||||||||||||||||||||||||||||||||||||||
| 180 | # provided, though, leave it alone. (Older versions just checked for | ||||||||||||||||||||||||||||||||||||||||||
| 181 | # truthiness, so a value of zero would still default to 30 seconds, which | ||||||||||||||||||||||||||||||||||||||||||
| 182 | # isn't ideal.) | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | if (!exists $return_settings->{connection_check_threshold}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $return_settings->{connection_check_threshold} = 30; | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | return $return_settings; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | # Given the settings to use, try to get a database connection | ||||||||||||||||||||||||||||||||||||||||||
| 193 | sub _get_connection { | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | my ($settings, $logger, $hook_exec) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_connection: not called CC=23 SCAR=63.1
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | # Assemble the DSN: | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $dsn = ''; | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my $driver = ''; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | if ($settings->{dsn}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $dsn = $settings->{dsn}; | |||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ($driver) = $dsn =~ m{^dbi:([^:]+)}i; | |||||||||||||||||||||||||||||||||||||||||
| 202 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $dsn = "dbi:" . $settings->{driver}; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $driver = $settings->{driver}; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my @extra_args; | |||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | # DBD::SQLite wants 'dbname', not 'database', so special-case this | ||||||||||||||||||||||||||||||||||||||||||
| 208 | # (DBI's documentation recommends that DBD::* modules should understand | ||||||||||||||||||||||||||||||||||||||||||
| 209 | # 'database', but older versions of DBD::SQLite didn't; let's make | ||||||||||||||||||||||||||||||||||||||||||
| 210 | # things easier for our users by handling this for them): | ||||||||||||||||||||||||||||||||||||||||||
| 211 | # (I asked in RT #61117 for DBD::SQLite to support 'database', too; this | ||||||||||||||||||||||||||||||||||||||||||
| 212 | # was included in DBD::SQLite 1.33, released Mon 20 May 2011. | ||||||||||||||||||||||||||||||||||||||||||
| 213 | # Special-casing may as well stay, rather than forcing dependency on | ||||||||||||||||||||||||||||||||||||||||||
| 214 | # DBD::SQLite 1.33. | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | if ($driver eq 'SQLite' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$driver eq "SQLite" and $settings->{"database"} and not $settings->{"dbname"}
$driver eq "SQLite" and $settings->{"database"}
MC/DC0%0/3
$driver eq "SQLite" and $settings->{"database"} and not $settings->{"dbname"}
$driver eq "SQLite"
$settings->{"database"}
not $settings->{"dbname"}
Truth table0%0/4
A and B and not(C)
A= $driver eq "SQLite"B= $settings->{"database"}C= not $settings->{"dbname"}
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | && $settings->{database} && !$settings->{dbname}) { | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $settings->{dbname} = delete $settings->{database}; | |||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | for (qw(database dbname host port sid server)) { | |||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if (exists $settings->{$_}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | push @extra_args, $_ . "=" . $settings->{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if (my $even_more_dsn_args = $settings->{dsn_extra}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | foreach my $arg ( keys %$even_more_dsn_args ) { | |||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | push @extra_args, $arg . '=' . $even_more_dsn_args->{$arg}; | |||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | $dsn .= ':' . join(';', @extra_args) if @extra_args; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | # If the app is configured to use UTF-8, the user will want text from the | ||||||||||||||||||||||||||||||||||||||||||
| 234 | # database in UTF-8 to Just Work, so if we know how to make that happen, do | ||||||||||||||||||||||||||||||||||||||||||
| 235 | # so, unless they've set the auto_utf8 plugin setting to a false value. | ||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | my $app_charset = $settings->{charset} || ""; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$settings->{'charset'} || ''
MC/DC0%0/1
$settings->{'charset'} || ''
$settings->{'charset'}
Truth table0%0/2
A
A= $settings->{'charset'}
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | my $auto_utf8 = exists $settings->{auto_utf8} ? $settings->{auto_utf8} : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | if (lc $app_charset eq 'utf-8' && $auto_utf8) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
lc $app_charset eq "utf-8" and $auto_utf8
MC/DC0%0/2
lc $app_charset eq "utf-8" and $auto_utf8
lc $app_charset eq "utf-8"
$auto_utf8
Truth table0%0/3
A and B
A= lc $app_charset eq "utf-8"B= $auto_utf8
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | # The option to pass to the DBI->connect call depends on the driver: | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my %param_for_driver = ( | |||||||||||||||||||||||||||||||||||||||||
| 242 | SQLite => 'sqlite_unicode', | ||||||||||||||||||||||||||||||||||||||||||
| 243 | mysql => 'mysql_enable_utf8', | ||||||||||||||||||||||||||||||||||||||||||
| 244 | Pg => 'pg_enable_utf8', | ||||||||||||||||||||||||||||||||||||||||||
| 245 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | my $param = $param_for_driver{$driver}; | |||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | if ($param && !$settings->{dbi_params}{$param}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$param and not $settings->{"dbi_params"}{$param}
MC/DC0%0/2
$param and not $settings->{"dbi_params"}{$param}
$param
not $settings->{"dbi_params"}{$param}
Truth table0%0/3
A and not(B)
A= $paramB= not $settings->{"dbi_params"}{$param}
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $logger->( | |||||||||||||||||||||||||||||||||||||||||
| 251 | debug => "Adding $param to DBI connection params" | ||||||||||||||||||||||||||||||||||||||||||
| 252 | . " to enable UTF-8 support" | ||||||||||||||||||||||||||||||||||||||||||
| 253 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $settings->{dbi_params}{$param} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | # To support the database_error hook, use DBI's HandleError option | ||||||||||||||||||||||||||||||||||||||||||
| 259 | $settings->{dbi_params}{HandleError} = sub { | ||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | my ($error, $handle) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $hook_exec->('database_error', $error, $handle); | |||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | my $dbh = DBI->connect($dsn, | ||||||||||||||||||||||||||||||||||||||||||
| 265 | $settings->{username}, $settings->{password}, $settings->{dbi_params} | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | if (!$dbh) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $logger->(error => "Database connection failed - " . $DBI::errstr); | |||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $hook_exec->('database_connection_failed', $settings); | |||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 272 | } elsif (exists $settings->{on_connect_do}) { | ||||||||||||||||||||||||||||||||||||||||||
| 273 | my $to_do = ref $settings->{on_connect_do} eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||
| 274 | ? $settings->{on_connect_do} | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | : [ $settings->{on_connect_do} ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | for (@$to_do) { | |||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | $dbh->do($_) or | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | $logger->(error => "Failed to perform on-connect command $_"); | ||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | $hook_exec->('database_connected', $dbh); | |||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | # Indicate whether queries generated by quick_query() etc in | ||||||||||||||||||||||||||||||||||||||||||
| 285 | # Dancer::Plugin::Database::Core::Handle should be logged or not; this seemed a | ||||||||||||||||||||||||||||||||||||||||||
| 286 | # little dirty, but DBI's docs encourage it | ||||||||||||||||||||||||||||||||||||||||||
| 287 | # ("You can stash private data into DBI handles via $h->{private_..._*}..") | ||||||||||||||||||||||||||||||||||||||||||
| 288 | $dbh->{private_dancer_plugin_database} = { | ||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | log_queries => $settings->{log_queries} || 0, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$settings->{'log_queries'} || 0
MC/DC0%0/1
$settings->{'log_queries'} || 0
$settings->{'log_queries'}
Truth table0%0/2
A
A= $settings->{'log_queries'}
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | # Re-bless it as a Dancer::Plugin::Database::Core::Handle object, to provide nice | ||||||||||||||||||||||||||||||||||||||||||
| 293 | # extra features (unless the config specifies a different class; if it does, | ||||||||||||||||||||||||||||||||||||||||||
| 294 | # this should be a subclass of Dancer::Plugin::Database::Core::Handle in order to | ||||||||||||||||||||||||||||||||||||||||||
| 295 | # extend the features provided by it, or a direct subclass of DBI::db (or | ||||||||||||||||||||||||||||||||||||||||||
| 296 | # even DBI::db itself) to bypass the features provided by D::P::D::Handle) | ||||||||||||||||||||||||||||||||||||||||||
| 297 | my $handle_class = | ||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | $settings->{handle_class} || 'Dancer::Plugin::Database::Core::Handle'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$settings->{'handle_class'} || 'Dancer::Plugin::Database::Core::Handle'
MC/DC0%0/1
$settings->{'handle_class'} || 'Dancer::Plugin::Database::Core::Handle'
$settings->{'handle_class'}
Truth table0%0/2
A
A= $settings->{'handle_class'}
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $package = $handle_class; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $package =~ s{::}{/}g; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | $package .= '.pm'; | |||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | require $package; | |||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | return bless($dbh => $handle_class); | |||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | # Check the connection is alive | ||||||||||||||||||||||||||||||||||||||||||
| 310 | sub _check_connection { | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | my $dbh = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_connection: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | return unless $dbh; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | if ($dbh->{Active} && (my $result = $dbh->ping)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dbh->{"Active"} and my $result = $dbh->ping
MC/DC0%0/2
$dbh->{"Active"} and my $result = $dbh->ping
$dbh->{"Active"}
my $result = $dbh->ping
Truth table0%0/3
A and B
A= $dbh->{"Active"}B= my $result = $dbh->ping
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | if (int($result)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | # DB driver itself claims all is OK, trust it: | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 317 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 318 | # It was "0 but true", meaning the default DBI ping implementation | ||||||||||||||||||||||||||||||||||||||||||
| 319 | # Implement our own basic check, by performing a real simple query. | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | my $ok; | |||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $ok = $dbh->do('select 1'); | |||||||||||||||||||||||||||||||||||||||||
| 323 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | return $ok; | |||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | David Precious, C<< <davidp at preshweb.co.uk> >> | ||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | Please report any bugs or feature requests to C<bug-dancer-plugin-database-core at rt.cpan.org>, or through | ||||||||||||||||||||||||||||||||||||||||||
| 339 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dancer-Plugin-Database-Core>. I will be notified, and then you'll | ||||||||||||||||||||||||||||||||||||||||||
| 340 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | perldoc Dancer::Plugin::Database::Core | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | You can also look for information at: | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dancer-Plugin-Database-Core> | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | L<http://annocpan.org/dist/Dancer-Plugin-Database-Core> | ||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | =item * CPAN Ratings | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | L<http://cpanratings.perl.org/d/Dancer-Plugin-Database-Core> | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | =item * Search CPAN | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | L<http://search.cpan.org/dist/Dancer-Plugin-Database-Core/> | ||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | Copyright 2013 David Precious. | ||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||
| 380 | under the terms of the the Artistic License (2.0). You may obtain a | ||||||||||||||||||||||||||||||||||||||||||
| 381 | copy of the full license at: | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | Any use, modification, and distribution of the Standard or Modified | ||||||||||||||||||||||||||||||||||||||||||
| 386 | Versions is governed by this Artistic License. By using, modifying or | ||||||||||||||||||||||||||||||||||||||||||
| 387 | distributing the Package, you accept this license. Do not use, modify, | ||||||||||||||||||||||||||||||||||||||||||
| 388 | or distribute the Package, if you do not accept this license. | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | If your Modified Version has been derived from a Modified Version made | ||||||||||||||||||||||||||||||||||||||||||
| 391 | by someone other than you, you are nevertheless required to ensure that | ||||||||||||||||||||||||||||||||||||||||||
| 392 | your Modified Version complies with the requirements of this license. | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | This license does not grant you the right to use any trademark, service | ||||||||||||||||||||||||||||||||||||||||||
| 395 | mark, tradename, or logo of the Copyright Holder. | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | This license includes the non-exclusive, worldwide, free-of-charge | ||||||||||||||||||||||||||||||||||||||||||
| 398 | patent license to make, have made, use, er to sell, sell, import and | ||||||||||||||||||||||||||||||||||||||||||
| 399 | otherwise transfer the Package with respect to any patent claims | ||||||||||||||||||||||||||||||||||||||||||
| 400 | licensable by the Copyright Holder that are necessarily infringed by the | ||||||||||||||||||||||||||||||||||||||||||
| 401 | Package. If you institute patent litigation (including a cross-claim or | ||||||||||||||||||||||||||||||||||||||||||
| 402 | counterclaim) against any party alleging that the Package constitutes | ||||||||||||||||||||||||||||||||||||||||||
| 403 | direct or contributory patent infringement, then this Artistic License | ||||||||||||||||||||||||||||||||||||||||||
| 404 | to you shall terminate on the date that such litigation is filed. | ||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER | ||||||||||||||||||||||||||||||||||||||||||
| 407 | AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. | ||||||||||||||||||||||||||||||||||||||||||
| 408 | THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||||||||||||||||||||||||||||||||||||||||||
| 409 | PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY | ||||||||||||||||||||||||||||||||||||||||||
| 410 | YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR | ||||||||||||||||||||||||||||||||||||||||||
| 411 | CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR | ||||||||||||||||||||||||||||||||||||||||||
| 412 | CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, | ||||||||||||||||||||||||||||||||||||||||||
| 413 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | 2 | 1; # End of Dancer::Plugin::Database::Core | |||||||||||||||||||||||||||||||||||||||||