| 1 | package DBD::SQLite::BundledExtensions; | ||||||||||
| 2 | |||||||||||
| 3 | # ABSTRACT: Provides a number of C extensions for DBD::SQLite and some functions to help load them | ||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | ▶ | use File::Find; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use File::Spec; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | our $VERSION="0.003"; | |||||||||
| 11 | |||||||||||
| 12 | 1 | for my $ext (qw/spellfix csv ieee754 nextchar percentile series totype wholenumber eval/) { | |||||||||
| 13 | 0 | ▶ | eval "sub load_${ext} {my (\$self, \$dbh)=\@_; \$self->_load_extension(\$dbh, '${ext}')}"; | ||||||||
|
Subroutine
load_csv: not called CC=1 SCAR=6.2
Subroutine
load_eval: not called CC=1 SCAR=6.2
Subroutine
load_ieee754: not called CC=1 SCAR=6.2
Subroutine
load_nextchar: not called CC=1 SCAR=6.2
Subroutine
load_percentile: not called CC=1 SCAR=6.2
Subroutine
load_series: not called CC=1 SCAR=6.2
Subroutine
load_spellfix: not called CC=1 SCAR=6.2
Subroutine
load_totype: not called CC=1 SCAR=6.2
Subroutine
load_wholenumber: not called CC=1 SCAR=6.2
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Pod
documented
Pod
documented
| |||||||||||
| 14 | } | ||||||||||
| 15 | |||||||||||
| 16 | 9 | ▶ | sub _load_extension { | ||||||||
|
Subroutine
_load_extension: called CC=2 SCAR=7.0
| |||||||||||
| 17 | 9 | my ($self, $dbh, $extension_name) = @_; | |||||||||
| 18 | |||||||||||
| 19 | 9 | my $file = $self->_locate_extension_library($extension_name); | |||||||||
| 20 | |||||||||||
| 21 | 9 | $dbh->sqlite_enable_load_extension(1); | |||||||||
| 22 | 9 | ▶ | $dbh->do("select load_extension(?)", {}, $file) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | or die "Cannot load '$extension_name' extension: " . $dbh->errstr(); | ||||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 9 | ▶ | sub _locate_extension_library { | ||||||||
|
Subroutine
_locate_extension_library: called CC=2 SCAR=6.9
| |||||||||||
| 27 | 9 | my ($self, $extension_name) = @_; | |||||||||
| 28 | 9 | my $sofile; | |||||||||
| 29 | |||||||||||
| 30 | 171 | ▶ | my $wanted = sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 31 | 171 | my $file = $File::Find::name; | |||||||||
| 32 | |||||||||||
| 33 | 171 | ▶ | if ($file =~ m/DBD-SQLite-BundledExtensions.\Q$extension_name\E\.(so|dll|dylib)$/i){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 9 | $sofile = $file; | |||||||||
| 35 | 9 | die; # bail out on the first one we find, this might need to be more configurable | |||||||||
| 36 | } | ||||||||||
| 37 | 9 | }; | |||||||||
| 38 | |||||||||||
| 39 | 9 | eval {find({wanted => $wanted, no_chdir => 1}, @INC);}; | |||||||||
| 40 | |||||||||||
| 41 | 9 | ▶ | if ($sofile) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 9 | $sofile = File::Spec->rel2abs($sofile); # Make it an absolute path, if it isn't already. Aids in portability | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 9 | return $sofile; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 1 | 1; | |||||||||
| 49 | __END__ | ||||||||||