AtteanX-Store-DBI-0.003/000755 000765 000024 00000000000 14764061656 014654 5ustar00gregstaff000000 000000 AtteanX-Store-DBI-0.003/inc/000755 000765 000024 00000000000 14764061652 015421 5ustar00gregstaff000000 000000 AtteanX-Store-DBI-0.003/SIGNATURE000644 000765 000024 00000010047 14764061656 016142 0ustar00gregstaff000000 000000 This file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.89. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: RIPEMD160 SHA256 231e365a175636d86b5fd3c221ab6ef7dd4f90221d882d2daa4feeca92288121 Changes SHA256 d11eeb015891675776020c76a0a1c86cae0bab64bdeadb7dfeba0447ebc0c623 MANIFEST SHA256 9348e6a18b008165a5a493bc27b8541e8950b0d1cc80d3693ae3e4aa55f415c7 META.yml SHA256 5f65e9f44871a5cc5f526e9340cdc02b54f3d73e5fce7eb4d94b555ecc208fb0 Makefile.PL SHA256 dafc4e443a6bd7fb7452fc631d486bf9b9362a9acc56b3a088435997d1359711 README.md SHA256 5c3a1aa3150c9b54ba92411d64b0024df0967e92dfc181f5c68f9e38631ac0db bin/attean_dbi SHA256 cd5397bbe618f5bbd4e12a33b0cf5d21114e771c2dbd0ce28e2135beb52c35a8 inc/Module/Install.pm SHA256 1b5430a46a35142ef8914d8c745196fca825defc9dfa7e389299bf294613825e inc/Module/Install/AuthorTests.pm SHA256 798836f9ccb8d204b1be31fc3835631f57e9d818b21a8f0d14bfcfb82ff4a72a inc/Module/Install/Base.pm SHA256 d64cd4c16f83c5baf11f64a44bea3a0abc060a49da5aba040f0eb01394bf75ab inc/Module/Install/Can.pm SHA256 668306ae2fad17b3049f885251b8679497c4eb8d5c4b0d13f5c95bda331d1f00 inc/Module/Install/DOAPChangeSets.pm SHA256 65d7a6098bf3f829e8c1c2865476d3537aa6f0ad0ffc9149e10812c856529043 inc/Module/Install/Fetch.pm SHA256 70c4b77acab3ff51dfb318110369607cb109e1c319459249623b787cf3859750 inc/Module/Install/Makefile.pm SHA256 14556386168007ce913e669fc08a332ccdb6140246fd55a90c879b5190c1b57a inc/Module/Install/Metadata.pm SHA256 63ec8405523ae67c33823dcf4b136a46f0711fb17a8b58b49ddd922ed6b69611 inc/Module/Install/Scripts.pm SHA256 b986592700675e11c2c62cb41fa24d9f4d15e077a0d317f372efcaa78d68a1d9 inc/Module/Install/Share.pm SHA256 4c746c02c5cc19bed4c352e76205b4adff4c45ce8310d71294e1b83c059659c2 inc/Module/Install/Win32.pm SHA256 d3d9b4583243c470ae895defa4c44564485b53693cba1c50ab0320768f443e97 inc/Module/Install/WriteAll.pm SHA256 a9503b6a76f33ba39f1f045d2705d5ed08536f8132b540d59777ac587f3a4151 lib/AtteanX/Store/DBI.pm SHA256 bfe7e8e7b04402a8b4701f7061b6bec75b7380c3bbc0ab200de167f4f6b5d74b lib/Test/AtteanX/Store/DBI.pm SHA256 3f2258c3a0dce58edc586bef7d112f8a264684ce8f522189cc2113992ed7f07c meta/changes.ttl SHA256 dd0b276f509f5c71d1031f4d27cd78f5d9a8d85f3afd8512c5e0e9b946bcce32 share/database-schema/mysql-create.sql SHA256 89f829942eb387bb8b569dd2d70412ca28a46c86a00b0b4350eb07d1de343e58 share/database-schema/mysql-drop.sql SHA256 820c4a16aef52754ed03d036615454ad8eabd09cc25d1ffa1648c679c4e0221e share/database-schema/postgresql-create.sql SHA256 2de18d403cfd956d62ea6135cd9f15d0507ffa86b1594e4edcd20f842b9f92a3 share/database-schema/postgresql-drop.sql SHA256 146fb0e54770a44b662808c1a31f6c33127c0aba927bb37c9b147907bf73e4d4 share/database-schema/sqlite-create.sql SHA256 89f829942eb387bb8b569dd2d70412ca28a46c86a00b0b4350eb07d1de343e58 share/database-schema/sqlite-drop.sql SHA256 25927a842ddbf2e42c50bc084f3dd407f70671a61f3ebf8a20c0bd378cb9ac93 t/store-dbi-mysql.t SHA256 d87fedd045ce2d8ab8dac05b2fdccf135cfa6ac082aafab531181431536e0d63 t/store-dbi-postgresql.t SHA256 4f14567e455b487ec9da1dec6735ec5b0b9099cb4a46f9fe590d466ca183ca16 t/store-dbi-sqlite.t SHA256 0efbd5cab373833735076832064c6c10f3f5c13216ac0e18347c48e3459223d9 xt/dawg11-mysql.t SHA256 a2f200695b73565e1e64451528e8005a44be4695e3fa875b6a90afb0e14c68b0 xt/dawg11-postgresql.t SHA256 1a2829c1f7c9e2c40880d3c2a671f1278d2e16a6edf30f46693852ece5c3c63a xt/dawg11-sqlite.t SHA256 81dae5e652e694c2acc7d105e32ba5f69edc343b22b2e1d47f95fdef8b441cd3 xt/pod-coverage.t SHA256 2b04b20ff767801fde2fb6435361dc8ca0a9b60dda6cb0bbd18dd52962e1c1a3 xt/pod.t -----BEGIN PGP SIGNATURE----- iF0EAREDAB0WIQSC+8GhU5AgVmDLxA+E8rpUyqjILQUCZ9BjqgAKCRCE8rpUyqjI LaH7AKCBqPiyVlrjrIO5dtGut5QSyuJPvQCfZsBGY21mxwL8bax5MMr3XkZYYcM= =GeK4 -----END PGP SIGNATURE----- AtteanX-Store-DBI-0.003/bin/000755 000765 000024 00000000000 14764061652 015420 5ustar00gregstaff000000 000000 AtteanX-Store-DBI-0.003/Changes000644 000765 000024 00000001053 14764061647 016146 0ustar00gregstaff000000 000000 AtteanX::Store::DBI =================== Created: 2016-03-14 Home page: Bug tracker: 0.003 2025-03-11 - (Update) Fix developer tests to silence warnings. 0.002 2020-12-12 - (Update) Add DBD::SQLite as a test prereq (#6). - (Update) Remove Math::Cartesian::Product from prereq list (#4). - (Update) Remove mistakenly added LICENSE file (#5). - (Update) Update copyright years (#3). 0.001 2020-12-02 - (Addition) Initial release. AtteanX-Store-DBI-0.003/MANIFEST000644 000765 000024 00000001731 14764061652 016003 0ustar00gregstaff000000 000000 bin/attean_dbi Changes inc/Module/Install.pm inc/Module/Install/AuthorTests.pm inc/Module/Install/Base.pm inc/Module/Install/Can.pm inc/Module/Install/DOAPChangeSets.pm inc/Module/Install/Fetch.pm inc/Module/Install/Makefile.pm inc/Module/Install/Metadata.pm inc/Module/Install/Scripts.pm inc/Module/Install/Share.pm inc/Module/Install/Win32.pm inc/Module/Install/WriteAll.pm lib/AtteanX/Store/DBI.pm lib/Test/AtteanX/Store/DBI.pm Makefile.PL MANIFEST This list of files META.yml meta/changes.ttl README.md share/database-schema/mysql-create.sql share/database-schema/mysql-drop.sql share/database-schema/postgresql-create.sql share/database-schema/postgresql-drop.sql share/database-schema/sqlite-create.sql share/database-schema/sqlite-drop.sql t/store-dbi-mysql.t t/store-dbi-postgresql.t t/store-dbi-sqlite.t xt/dawg11-mysql.t xt/dawg11-postgresql.t xt/dawg11-sqlite.t xt/pod-coverage.t xt/pod.t SIGNATURE Public-key signature (added by MakeMaker) AtteanX-Store-DBI-0.003/meta/000755 000765 000024 00000000000 14764061652 015576 5ustar00gregstaff000000 000000 AtteanX-Store-DBI-0.003/t/000755 000765 000024 00000000000 14764061652 015113 5ustar00gregstaff000000 000000 AtteanX-Store-DBI-0.003/xt/000755 000765 000024 00000000000 14764061652 015303 5ustar00gregstaff000000 000000 AtteanX-Store-DBI-0.003/PaxHeader/README.md000644 000765 000024 00000000225 13761617237 020101 xustar00gregstaff000000 000000 30 mtime=1606885023.242905658 64 LIBARCHIVE.xattr.com.apple.TextEncoding=VVRGLTg7MTM0MjE3OTg0 55 SCHILY.xattr.com.apple.TextEncoding=UTF-8;134217984 AtteanX-Store-DBI-0.003/README.md000644 000765 000024 00000000626 13761617237 016135 0ustar00gregstaff000000 000000 AtteanX::Store::DBI =================== An Attean quadstore implementation based on relational databases. Getting Help ------------ A group of perl-rdf developers are usually available in the [perlrdf IRC channel](irc://irc.perl.org/perlrdf) where we're happy to answer questions. You can also: * Create a new [GitHub Issue](https://github.com/kasei/atteanx-store-dbi/issues) or submit a pull request AtteanX-Store-DBI-0.003/META.yml000644 000765 000024 00000002262 14764061647 016127 0ustar00gregstaff000000 000000 --- abstract: 'Database quad-store' author: - 'Gregory Todd Williams C<< >>' - 'Gregory Todd Williams ' build_requires: DBD::SQLite: 0 ExtUtils::MakeMaker: 6.59 HTTP::Message::PSGI: 0 Test::Exception: 0 Test::LWP::UserAgent: 0 Test::Modern: 0 Test::Moose: 0 Test::More: 0.88 Test::Roo: 0 configure_requires: ExtUtils::MakeMaker: 6.59 distribution_type: module dynamic_config: 1 generated_by: 'Module::Install version 1.21' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: AtteanX-Store-DBI no_index: directory: - inc - share - t - xt requires: Attean: 0.013 Cache::LRU: 0 DBI: 0 DBIx::MultiStatementDo: 0 File::ShareDir: 0 File::Slurp: 0 List::MoreUtils: 0 Moo: 1.006 MooX::Log::Any: 0 Try::Tiny: 0 Type::Tiny: 0 namespace::clean: 0 perl: 5.14.0 resources: IRC: irc://irc.perl.org/#perlrdf bugtracker: https://github.com/kasei/atteanx-store-dbi/issues homepage: https://metacpan.org/release/AtteanX-Store-DBI/ license: http://dev.perl.org/licenses/ repository: https://github.com/kasei/atteanx-store-dbi/ version: '0.003' AtteanX-Store-DBI-0.003/lib/000755 000765 000024 00000000000 14764061652 015416 5ustar00gregstaff000000 000000 AtteanX-Store-DBI-0.003/PaxHeader/Makefile.PL000644 000765 000024 00000000225 13764534140 020566 xustar00gregstaff000000 000000 30 mtime=1607645280.153539003 64 LIBARCHIVE.xattr.com.apple.TextEncoding=VVRGLTg7MTM0MjE3OTg0 55 SCHILY.xattr.com.apple.TextEncoding=UTF-8;134217984 AtteanX-Store-DBI-0.003/Makefile.PL000644 000765 000024 00000002550 13764534140 016620 0ustar00gregstaff000000 000000 use strict; use warnings; use inc::Module::Install; name 'AtteanX-Store-DBI'; all_from 'lib/AtteanX/Store/DBI.pm'; author 'Gregory Todd Williams '; license 'perl'; test_requires 'Test::Exception' => 0; test_requires 'Test::Modern' => 0; test_requires 'Test::Moose' => 0; test_requires 'Test::More' => 0.88; test_requires 'Test::Roo' => 0; test_requires 'HTTP::Message::PSGI' => 0; test_requires 'Test::LWP::UserAgent' => 0; test_requires 'DBD::SQLite' => 0; perl_version '5.014'; requires 'Attean' => 0.013; requires 'List::MoreUtils' => 0; requires 'Moo' => 1.006000; requires 'MooX::Log::Any' => 0; requires 'namespace::clean' => 0; requires 'Try::Tiny' => 0; requires 'Type::Tiny' => 0; requires 'File::Slurp' => 0; requires 'File::ShareDir' => 0; requires 'DBI' => 0; requires 'Cache::LRU' => 0; requires 'DBI' => 0; requires 'DBIx::MultiStatementDo' => 0; resources( 'homepage' => "https://metacpan.org/release/AtteanX-Store-DBI/", 'repository' => "https://github.com/kasei/atteanx-store-dbi/", 'bugtracker' => "https://github.com/kasei/atteanx-store-dbi/issues", 'IRC' => "irc://irc.perl.org/#perlrdf", ); author_tests('xt'); install_share; install_script glob('bin/attean_*'); write_doap_changes "meta/changes.ttl", "Changes", "turtle"; sign; WriteAll; AtteanX-Store-DBI-0.003/share/000755 000765 000024 00000000000 14764061652 015752 5ustar00gregstaff000000 000000 AtteanX-Store-DBI-0.003/share/database-schema/000755 000765 000024 00000000000 14764061652 020754 5ustar00gregstaff000000 000000 AtteanX-Store-DBI-0.003/share/database-schema/PaxHeader/mysql-create.sql000644 000765 000024 00000000167 13133671135 026050 xustar00gregstaff000000 000000 64 LIBARCHIVE.xattr.com.apple.TextEncoding=VVRGLTg7MTM0MjE3OTg0 55 SCHILY.xattr.com.apple.TextEncoding=UTF-8;134217984 AtteanX-Store-DBI-0.003/share/database-schema/mysql-create.sql000644 000765 000024 00000001602 13133671135 024072 0ustar00gregstaff000000 000000 CREATE TABLE IF NOT EXISTS attean_version ( attean_version VARCHAR(16), store_version VARCHAR(16), created TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; CREATE TABLE IF NOT EXISTS term ( term_id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, `type` ENUM('iri', 'literal', 'blank'), datatype_id BIGINT REFERENCES term(term_id), value LONGTEXT NOT NULL, language TEXT, INDEX (`type`, datatype_id, value(64), language(64)) ) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; CREATE TABLE IF NOT EXISTS quad ( subject BIGINT UNSIGNED NOT NULL REFERENCES term, predicate BIGINT UNSIGNED NOT NULL REFERENCES term, object BIGINT UNSIGNED NOT NULL REFERENCES term, graph BIGINT UNSIGNED NOT NULL REFERENCES term, PRIMARY KEY (subject, predicate, object, graph), KEY (predicate,object,graph,subject), INDEX (graph) ); AtteanX-Store-DBI-0.003/share/database-schema/PaxHeader/postgresql-drop.sql000644 000765 000024 00000000167 13133671713 026611 xustar00gregstaff000000 000000 64 LIBARCHIVE.xattr.com.apple.TextEncoding=VVRGLTg7MTM0MjE3OTg0 55 SCHILY.xattr.com.apple.TextEncoding=UTF-8;134217984 AtteanX-Store-DBI-0.003/share/database-schema/postgresql-drop.sql000644 000765 000024 00000000134 13133671713 024632 0ustar00gregstaff000000 000000 DROP TABLE quad; DROP TABLE term; DROP TYPE TERM_TYPE; DROP TABLE IF EXISTS attean_version; AtteanX-Store-DBI-0.003/share/database-schema/PaxHeader/sqlite-create.sql000644 000765 000024 00000000167 13133667440 026210 xustar00gregstaff000000 000000 64 LIBARCHIVE.xattr.com.apple.TextEncoding=VVRGLTg7MTM0MjE3OTg0 55 SCHILY.xattr.com.apple.TextEncoding=UTF-8;134217984 AtteanX-Store-DBI-0.003/share/database-schema/sqlite-create.sql000644 000765 000024 00000001440 13133667440 024232 0ustar00gregstaff000000 000000 CREATE TABLE IF NOT EXISTS attean_version ( attean_version VARCHAR(16), store_version VARCHAR(16), created DATETIME DEFAULT CURRENT_TIMESTAMP, updated DATETIME DEFAULT CURRENT_TIMESTAMP ); CREATE TABLE IF NOT EXISTS term ( term_id INTEGER PRIMARY KEY, type CHAR(7), datatype_id BIGINT REFERENCES term(term_id), value LONGTEXT NOT NULL, language TEXT ); CREATE UNIQUE INDEX term_idx ON term (type, datatype_id, language, value); CREATE TABLE IF NOT EXISTS quad ( subject BIGINT NOT NULL REFERENCES term, predicate BIGINT NOT NULL REFERENCES term, object BIGINT NOT NULL REFERENCES term, graph BIGINT NOT NULL REFERENCES term, PRIMARY KEY (subject, predicate, object, graph) ); CREATE INDEX quad_pogs_idx ON quad (predicate,object,graph,subject); CREATE INDEX quad_g ON quad (graph); AtteanX-Store-DBI-0.003/share/database-schema/PaxHeader/mysql-drop.sql000644 000765 000024 00000000167 13133671055 025552 xustar00gregstaff000000 000000 64 LIBARCHIVE.xattr.com.apple.TextEncoding=VVRGLTg7MTM0MjE3OTg0 55 SCHILY.xattr.com.apple.TextEncoding=UTF-8;134217984 AtteanX-Store-DBI-0.003/share/database-schema/mysql-drop.sql000644 000765 000024 00000000106 13133671055 023572 0ustar00gregstaff000000 000000 DROP TABLE quad; DROP TABLE term; DROP TABLE IF EXISTS attean_version;AtteanX-Store-DBI-0.003/share/database-schema/PaxHeader/sqlite-drop.sql000644 000765 000024 00000000167 13133672072 025706 xustar00gregstaff000000 000000 64 LIBARCHIVE.xattr.com.apple.TextEncoding=VVRGLTg7MTM0MjE3OTg0 55 SCHILY.xattr.com.apple.TextEncoding=UTF-8;134217984 AtteanX-Store-DBI-0.003/share/database-schema/sqlite-drop.sql000644 000765 000024 00000000106 13133672072 023726 0ustar00gregstaff000000 000000 DROP TABLE quad; DROP TABLE term; DROP TABLE IF EXISTS attean_version;AtteanX-Store-DBI-0.003/share/database-schema/PaxHeader/postgresql-create.sql000644 000765 000024 00000000167 13133667350 027112 xustar00gregstaff000000 000000 64 LIBARCHIVE.xattr.com.apple.TextEncoding=VVRGLTg7MTM0MjE3OTg0 55 SCHILY.xattr.com.apple.TextEncoding=UTF-8;134217984 AtteanX-Store-DBI-0.003/share/database-schema/postgresql-create.sql000644 000765 000024 00000001502 13133667350 025133 0ustar00gregstaff000000 000000 CREATE TABLE IF NOT EXISTS attean_version ( attean_version VARCHAR(16), store_version VARCHAR(16), created TIMESTAMP DEFAULT NOW(), updated TIMESTAMP DEFAULT NOW() ); CREATE TYPE TERM_TYPE AS ENUM ('iri', 'literal', 'blank'); CREATE TABLE IF NOT EXISTS term ( term_id SERIAL PRIMARY KEY, type TERM_TYPE, datatype_id BIGINT REFERENCES term(term_id), value TEXT NOT NULL, language TEXT, UNIQUE (datatype_id, value, language) ); CREATE TABLE IF NOT EXISTS quad ( subject BIGINT NOT NULL REFERENCES term, predicate BIGINT NOT NULL REFERENCES term, object BIGINT NOT NULL REFERENCES term, graph BIGINT NOT NULL REFERENCES term, PRIMARY KEY (subject, predicate, object, graph) ); CREATE INDEX IF NOT EXISTS quad_graph_idx ON quad (graph); CREATE INDEX IF NOT EXISTS quad_pogs_idx ON quad (predicate,object,graph,subject); AtteanX-Store-DBI-0.003/lib/Test/000755 000765 000024 00000000000 14764061652 016335 5ustar00gregstaff000000 000000 AtteanX-Store-DBI-0.003/lib/AtteanX/000755 000765 000024 00000000000 14764061652 016762 5ustar00gregstaff000000 000000 AtteanX-Store-DBI-0.003/lib/AtteanX/Store/000755 000765 000024 00000000000 14764061652 020056 5ustar00gregstaff000000 000000 AtteanX-Store-DBI-0.003/lib/AtteanX/Store/PaxHeader/DBI.pm000644 000765 000024 00000000425 14764061602 022757 xustar00gregstaff000000 000000 30 mtime=1741710210.357637604 69 LIBARCHIVE.xattr.com.apple.lastuseddate#PS=BBrHXwAAAABQw6UjAAAAAA 59 SCHILY.xattr.com.apple.lastuseddate#PS=_På# 64 LIBARCHIVE.xattr.com.apple.TextEncoding=VVRGLTg7MTM0MjE3OTg0 55 SCHILY.xattr.com.apple.TextEncoding=UTF-8;134217984 AtteanX-Store-DBI-0.003/lib/AtteanX/Store/DBI.pm000644 000765 000024 00000066067 14764061602 021024 0ustar00gregstaff000000 000000 =head1 NAME AtteanX::Store::DBI - Database quad-store =head1 VERSION This document describes AtteanX::Store::DBI version 0.003 =head1 SYNOPSIS use Attean; my $store = Attean->get_store('DBI')->new( dbh => $dbh ); =head1 DESCRIPTION AtteanX::Store::DBI provides a quad-store backed by a relational database. =head1 ATTRIBUTES =over 4 =item C<< dbh >> =back =cut use utf8; use v5.14; use warnings; package AtteanX::Store::DBI { our $VERSION = '0.003'; use Moo; use DBI; use Attean 0.013; use DBI::Const::GetInfoType; use Type::Tiny::Role; use Types::Standard qw(Int Str ArrayRef HashRef ConsumerOf InstanceOf); use Encode; use Cache::LRU; use Set::Scalar; use DBIx::MultiStatementDo; use List::MoreUtils qw(zip); use List::Util qw(any all first); use File::ShareDir qw(dist_dir dist_file); use File::Slurp; use Scalar::Util qw(refaddr reftype blessed); use namespace::clean; with 'Attean::API::MutableQuadStore'; with 'Attean::API::BulkUpdatableStore'; with 'Attean::API::QuadStore'; with 'Attean::API::CostPlanner'; my @pos_names = Attean::API::Quad->variables; =head1 ROLES This class consumes L, L, and L. =head1 METHODS =over 4 =item C<< new ( dbh => $dbh ) >> Returns a new quad-store object backed by the database referenced by the supplied database handle. =cut has dbh => (is => 'ro', isa => InstanceOf['DBI::db'], required => 1); has _i2t_cache => (is => 'ro', default => sub { Cache::LRU->new( size => 256 ) }); has _t2i_cache => (is => 'ro', default => sub { Cache::LRU->new( size => 256 ) }); =item C<< init() >> Create the tables and indexes required for using the database as a quadstore. =cut sub init { my $self = shift; my $dbh = $self->dbh; my $batch = DBIx::MultiStatementDo->new( dbh => $dbh ); my $file = $self->create_schema_file or die 'No schema files available for store initialization'; my $sql = read_file($file); $batch->do($sql); } =item C<< temporary_store() >> Returns a temporary (in-memory, SQLite) store. =cut sub temporary_store { my $class = shift; my $dbh = DBI->connect('dbi:SQLite:dbname=:memory:', '', ''); my $store = $class->new(dbh => $dbh); $store->init(); return $store; } sub _last_insert_id { my $self = shift; my $table = shift; my $dbh = $self->dbh; return $dbh->last_insert_id(undef, undef, $table, undef); } sub _get_term { my $self = shift; my $id = shift; if (my $term = $self->_i2t_cache->get($id)) { return $term; } my $sth = $self->dbh->prepare('SELECT term.type, term.value, dtterm.value AS datatype, term.language FROM term LEFT JOIN term dtterm ON (term.datatype_id = dtterm.term_id) WHERE term.term_id = ?'); $sth->execute($id); my $row = $sth->fetchrow_hashref; my $type = $row->{type}; my $term; my $value = $row->{value}; my $datatype = $row->{datatype}; my $lang = $row->{language}; if ($type eq 'iri') { $term = Attean::IRI->new( value => $value ); } elsif ($type eq 'blank') { $term = Attean::Blank->new( value => $value ); } elsif ($type eq 'literal') { my %args = (value => $value, datatype => Attean::IRI->new(value => $datatype)); if ($lang) { $args{language} = $lang; } $term = Attean::Literal->new( %args ); } if ($term) { $self->_i2t_cache->set($id => $term); return $term; } Carp::confess "Failed to load term values for bad ID " . Dumper($id); } sub _get_term_id { my $self = shift; my $term = shift; if (my $id = $self->_t2i_cache->get($term->as_string)) { return $id; } my $dbh = $self->dbh; my $tid; if ($term->does('Attean::API::IRI')) { my $sth = $dbh->prepare('SELECT term_id FROM term WHERE type = ? AND value = ?'); my $value = $term->value; $sth->execute('iri', $value); ($tid) = $sth->fetchrow_array; } elsif ($term->does('Attean::API::Blank')) { my $sth = $dbh->prepare('SELECT term_id FROM term WHERE type = ? AND value = ?'); my $value = $term->value; $sth->execute('blank', $value); ($tid) = $sth->fetchrow_array; } elsif ($term->does('Attean::API::Literal')) { my $dtid = $self->_get_or_create_term_id($term->datatype); my $sth = $dbh->prepare('SELECT term_id FROM term WHERE type = ? AND value = ? AND datatype_id = ? AND language = ?'); my $value = $term->value; my $lang = $term->language; $sth->execute('literal', $value, $dtid, $lang); ($tid) = $sth->fetchrow_array; } if (defined($tid)) { $self->_t2i_cache->set($term->as_string => $tid); return $tid; } return; } sub _get_or_create_term_id { my $self = shift; my $term = shift; if (my $id = $self->_t2i_cache->get($term->as_string)) { return $id; } my $dbh = $self->dbh; my $tid; my $insert_term_sth = $dbh->prepare('INSERT INTO term (type, value, datatype_id, language) VALUES (?, ?, ?, ?)'); if ($term->does('Attean::API::IRI')) { my $sth = $dbh->prepare('SELECT term_id FROM term WHERE type = ? AND value = ?'); my $value = $term->value; $sth->execute('iri', $value); ($tid) = $sth->fetchrow_array; unless (defined($tid)) { $insert_term_sth->execute('iri', $value, undef, undef); $tid = $self->_last_insert_id('term'); } } elsif ($term->does('Attean::API::Blank')) { my $sth = $dbh->prepare('SELECT term_id FROM term WHERE type = ? AND value = ?'); my $value = $term->value; $sth->execute('blank', $value); ($tid) = $sth->fetchrow_array; unless (defined($tid)) { $insert_term_sth->execute('blank', $value, undef, undef); $tid = $self->_last_insert_id('term'); } } elsif ($term->does('Attean::API::Literal')) { my $dtid = $self->_get_or_create_term_id($term->datatype); my $sql = 'SELECT term_id FROM term WHERE type = ? AND value = ? AND datatype_id = ?'; my $value = $term->value; my @bind = ('literal', $value, $dtid); my $lang = $term->language; if ($lang) { $sql .= ' AND language = ?'; push(@bind, $lang); } my $sth = $dbh->prepare($sql); $sth->execute(@bind); ($tid) = $sth->fetchrow_array; unless (defined($tid)) { $insert_term_sth->execute('literal', $value, $dtid, $lang); $tid = $self->_last_insert_id('term'); } } else { die "Failed to get ID for term: " . $term->as_string; } if (defined($tid)) { $self->_t2i_cache->set($term->as_string => $tid); return $tid; } die; } =item C<< get_quads ( $subject, $predicate, $object, $graph ) >> Returns a stream object of all statements matching the specified subject, predicate and objects. Any of the arguments may be undef to match any value, or an ARRAY reference of terms that are allowable in the respective quad position. =cut sub get_quads { my $self = shift; my @nodes = map { ref($_) eq 'ARRAY' ? $_ : [$_] } @_; my @where; my @bind; foreach my $i (0 .. 3) { my $name = $pos_names[$i]; my $terms = $nodes[$i]; if (defined($terms)) { unless (scalar(@$terms) == 1 and not defined($terms->[0])) { unless (any { $_->does('Attean::API::Variable') } @$terms) { my @ids = map { $self->_get_term_id($_) } @$terms; unless (scalar(@ids)) { return Attean::ListIterator->new( values => [], item_type => 'Attean::API::Quad' ); } push(@where, "$name IN (" . join(', ', ('?') x scalar(@ids)) . ")"); push(@bind, @ids); } } } } my $sql = 'SELECT subject, predicate, object, graph FROM quad'; if (scalar(@where)) { $sql .= ' WHERE ' . join(' AND ', @where); } my $sth = $self->dbh->prepare($sql); $sth->execute(@bind); my $ok = 1; my $sub = sub { return unless ($ok); if (my $row = $sth->fetchrow_arrayref) { my @terms = map { $self->_get_term($_) } @$row; my $quad = Attean::Quad->new(zip @pos_names, @terms); return $quad; } $ok = 0; return; }; my $iter = Attean::CodeIterator->new( generator => $sub, item_type => 'Attean::API::Quad' ); return $iter; } =item C<< count_quads ( $subject, $predicate, $object, $graph ) >> Returns the count of all statements matching the specified subject, predicate and objects. Any of the arguments may be undef to match any value, or an ARRAY reference of terms that are allowable in the respective quad position. =cut sub count_quads { my $self = shift; my @nodes = map { ref($_) eq 'ARRAY' ? $_ : [$_] } @_; my @where; my @bind; foreach my $i (0 .. 3) { my $name = $pos_names[$i]; my $terms = $nodes[$i]; if (defined($terms)) { unless (scalar(@$terms) == 1 and not defined($terms->[0])) { unless (any { $_->does('Attean::API::Variable') } @$terms) { my @ids = map { $self->_get_term_id($_) } @$terms; return 0 unless scalar(@ids); push(@where, "$name IN (" . join(', ', ('?') x scalar(@ids)) . ")"); push(@bind, @ids); } } } } my $sql = 'SELECT COUNT(*) FROM quad'; if (scalar(@where)) { $sql .= ' WHERE ' . join(' AND ', @where); } my $sth = $self->dbh->prepare($sql); $sth->execute(@bind); my ($count) = $sth->fetchrow_array; return $count; } =item C<< get_graphs >> Returns an iterator over the Attean::API::Term objects comprising the set of graphs of the stored quads. =cut sub get_graphs { my $self = shift; my $sth = $self->dbh->prepare('SELECT DISTINCT value FROM quad JOIN term ON (quad.graph = term.term_id)'); $sth->execute; my $sub = sub { my $row = $sth->fetchrow_arrayref; return unless ref($row); my ($value) = @$row; return Attean::IRI->new(value => $value); }; return Attean::CodeIterator->new( generator => $sub, item_type => 'Attean::API::Term' ); } # ----------------------------------------------------------------------------- =item C<< add_quad ( $quad ) >> Adds the specified C<$quad> to the underlying model. =cut sub add_quad { my $self = shift; my $st = shift; my @ids = map { $self->_get_or_create_term_id($_) } $st->values; if (any { not defined($_) } @ids) { return; } my $type = $self->database_type; my @bind = @ids; my $sql = 'INSERT INTO quad (subject, predicate, object, graph) VALUES (?, ?, ?, ?)'; if ($type eq 'sqlite') { $sql = 'INSERT OR IGNORE INTO quad (subject, predicate, object, graph) VALUES (?, ?, ?, ?)'; } elsif ($type eq 'mysql') { $sql = 'INSERT IGNORE INTO quad (subject, predicate, object, graph) VALUES (?, ?, ?, ?)'; } elsif ($type eq 'postgresql') { $sql = 'INSERT INTO quad (subject, predicate, object, graph) SELECT ?, ?, ?, ? WHERE NOT EXISTS (SELECT 1 FROM quad WHERE subject = ? AND predicate = ? AND object = ? AND graph = ?)'; push(@bind, @ids); } my $sth = $self->dbh->prepare($sql); $sth->execute(@bind); return; } =item C<< remove_quad ( $statement ) >> Removes the specified C<$statement> from the underlying model. =cut sub remove_quad { my $self = shift; my $st = shift; my @ids = map { $self->_get_term_id($_) } $st->values; unless (scalar(@ids) == 4) { return; } unless (all { defined($_) } @ids) { return; } my $sth = $self->dbh->prepare('DELETE FROM quad WHERE subject = ? AND predicate = ? AND object = ? AND graph = ?'); $sth->execute(@ids); return; } =item C<< create_graph( $graph ) >> This is a no-op function for the memory quad-store. =cut sub create_graph { # no-op on a quad-store } =item C<< drop_graph( $graph ) >> Removes all quads with the given C<< $graph >>. =cut sub drop_graph { my $self = shift; return $self->clear_graph(@_); } =item C<< clear_graph( $graph ) >> Removes all quads with the given C<< $graph >>. =cut sub clear_graph { my $self = shift; my $graph = shift; my $gid = $self->_get_term_id($graph); return unless defined($gid); my $sth = $self->dbh->prepare('DELETE FROM quad WHERE graph = ?'); $sth->execute($gid); return; } =item C<< begin_transaction >> Begin a database transaction. =cut sub begin_transaction { # warn 'begin transaction'; my $self = shift; $self->dbh->begin_work; } =item C<< abort_transaction >> Rollback the current database transaction. =cut sub abort_transaction { # warn 'abort transaction'; my $self = shift; $self->dbh->rollback; } =item C<< end_transaction >> Commit the current database transaction. =cut sub end_transaction { # warn 'end transaction'; my $self = shift; $self->dbh->commit; } =item C<< begin_bulk_updates >> Begin a database transaction. =cut sub begin_bulk_updates { my $self = shift; $self->dbh->begin_work; } =item C<< end_bulk_updates >> Commit the current database transaction. =cut sub end_bulk_updates { my $self = shift; $self->dbh->commit; } =item C<< database_type >> Returns the database type name as a string (e.g. 'mysql', 'sqlite', or 'postgresql'). =cut sub database_type { my $self = shift; my $dbh = $self->dbh; # warn $dbh->get_info($GetInfoType{SQL_DRIVER_NAME}); my $type = lc($dbh->get_info($GetInfoType{SQL_DBMS_NAME})); return $type; } =item C<< initialize_version >> Insert data into the attean_version table. =cut sub initialize_version { my $self = shift; my $dbh = $self->dbh; $dbh->do('DELETE FROM attean_version'); my $sql = 'INSERT INTO attean_version (attean_version, store_version) VALUES (?, ?);'; $dbh->do($sql, undef, $Attean::VERSION, $AtteanX::Store::DBI::VERSION); } =item C<< create_schema_file >> Returns the path to the file containing the database DDL for quadstore creation for the current database type if available, undef otherwise. =cut sub create_schema_file { my $self = shift; my $type = $self->database_type; my $dir = $ENV{ATTEAN_SHAREDIR} || eval { dist_dir('AtteanX-Store-DBI') } || 'share'; my $file = File::Spec->catfile($dir, 'database-schema', sprintf('%s-create.sql', $type)); if (-r $file) { return $file; } return; } =item C<< drop_schema_file >> Returns the path to the file containing the database DDL for quadstore deletion for the current database type if available, undef otherwise. =cut sub drop_schema_file { my $self = shift; my $type = $self->database_type; my $dir = $ENV{ATTEAN_SHAREDIR} || eval { dist_dir('AtteanX-Store-DBI') } || 'share'; my $file = File::Spec->catfile($dir, 'database-schema', sprintf('%s-drop.sql', $type)); if (-r $file) { return $file; } return; } =item C<< available_database_types >> Returns the names of the database types for which the system has schemas available to create and drop quadstore tables. =cut sub available_database_types { my $self = shift; my $dir = $ENV{ATTEAN_SHAREDIR} || eval { dist_dir('AtteanX-Store-DBI') } || 'share'; my $pat = File::Spec->catfile($dir, 'database-schema', '*-create.sql'); my @files = glob($pat); my @types = map { /(\w+)-create.sql/ } @files; return @types; } =item C<< dbi_connect_args ( $type, %args ) >> =item C<< dbi_connect_args ( %args ) >> Returns a quad C<< $dsn, $user, $password, \%connect_args >> suitable for passing to C<< DBI->connect >> to obtain a database handle to be used in constructing a C<< AtteanX::Store::DBI >> quadstore. C<< %args >> must contain a value for the C<< database >> key. It may also contain values for the optional keys: C<< user >>, C<< password >>, C<< host >>, and C<< port >>. If invoked as a class method, the C<< $type >> parameter is required, and must be one of the database types returned by C<< available_database_types >>. If invoked as an object method, the C<< $type >> parameter must not be included; this information will be obtained directly from the C<< AtteanX::Store::DBI >> object. =cut sub dbi_connect_args { my $self = shift; my $type = blessed($self) ? $self->database_type : shift; my %args = @_; my $database = $args{database}; my $user = $args{user}; my $password = $args{password}; my $host = $args{host}; my $port = $args{port}; my $dsn; my %connect_args; $connect_args{RaiseError} = 1; if ($type eq 'mysql') { $dsn = "DBI:mysql:database=${database}"; if (defined($host)) { $dsn .= ";host=$host"; } if (defined($port)) { $dsn .= ";port=$port"; } $connect_args{mysql_enable_utf8} = 1; } elsif ($type eq 'postgresql') { $dsn = "DBI:Pg:dbname=${database}"; if (defined($host)) { $dsn .= ";host=$host"; } if (defined($port)) { $dsn .= ";port=$port"; } } elsif ($type eq 'sqlite') { $dsn = "DBI:SQLite:dbname=${database}"; $connect_args{sqlite_unicode} = 1; } return ($dsn, $user, $password, \%connect_args); } =item C<< plans_for_algebra( $algebra, $model, $active_graphs, $default_graphs ) >> For BGP algebras, returns a DBI-specific L object, otherwise returns undef. =cut sub plans_for_algebra { my $self = shift; my $algebra = shift; my $model = shift; my $active_graphs = shift; my $default_graphs = shift; return unless ($algebra); my %args = @_; my $counter = $args{dbi_filter_counter}++; if ($algebra->isa('Attean::Algebra::Filter')) { my $e = $algebra->expression; if ($e->isa('Attean::FunctionExpression')) { if ($e->operator =~ m/IS(IRI|LITERAL|BLANK)/i) { my $type = lc($1); my ($operand) = @{ $e->children }; if ($operand->isa('Attean::ValueExpression') and $operand->value->does('Attean::API::Variable')) { my $var = $operand->value; if (my ($plan) = $self->plans_for_algebra($algebra->child, $model, $active_graphs, $default_graphs, %args)) { if ($plan->isa('AtteanX::Store::DBI::Plan')) { if (exists $plan->variables->{ $var->value }) { my ($table, $col) = @{ $plan->variables->{ $var->value } }; my $ref = join('.', map { $self->dbh->quote_identifier($_) } ($table, $col)); my $typecol = $self->dbh->quote_identifier('type'); push(@{ $plan->where }, "$ref IN (SELECT term_id FROM term WHERE ${typecol} = ?)"); push(@{ $plan->bindings }, $type); return $plan; } } } } } elsif ($e->operator eq 'STRSTARTS' or $e->operator eq 'CONTAINS') { my ($varexpr, $pat) = @{ $e->children }; if ($varexpr->isa('Attean::ValueExpression') and $varexpr->value->does('Attean::API::Variable') and $pat->isa('Attean::ValueExpression') and $pat->value->does('Attean::API::Literal')) { if (my ($plan) = $self->plans_for_algebra($algebra->child, $model, $active_graphs, $default_graphs, %args)) { if ($plan->isa('AtteanX::Store::DBI::Plan')) { my $var = $varexpr->value; my $varname = $var->value; if (exists $plan->variables->{ $var->value }) { my ($table, $col) = @{ $plan->variables->{ $var->value } }; my $literal = $pat->value; my $ref = join('.', map { $self->dbh->quote_identifier($_) } ($table, $col)); my $typecol = $self->dbh->quote_identifier('type'); my $termtable = "tf$counter"; push(@{ $plan->tables }, ['term', $termtable]); my $db = $self->database_type; return unless ($db eq 'mysql' or $db eq 'postgresql' or $db eq 'sqlite'); push(@{ $plan->where }, "$ref = $termtable.term_id"); push(@{ $plan->where }, "$termtable.$typecol = ?"); # TODO: Remove this (and the bindings below) if $varexpr is STR(?var) instead of just ?var. my $op = ($e->operator eq 'STRSTARTS') ? '=' : '>='; if ($db eq 'mysql') { push(@{ $plan->where }, "LOCATE(?, $termtable.value) ${op} ?"); push(@{ $plan->bindings }, 'literal'); push(@{ $plan->bindings }, $literal->value); push(@{ $plan->bindings }, 1); } elsif ($db eq 'postgresql') { push(@{ $plan->where }, "STRPOS($termtable.value, ?) ${op} ?"); push(@{ $plan->bindings }, 'literal'); push(@{ $plan->bindings }, $literal->value); push(@{ $plan->bindings }, 1); } elsif ($db eq 'sqlite') { push(@{ $plan->where }, "INSTR($termtable.value, ?) ${op} 1"); push(@{ $plan->bindings }, 'literal'); push(@{ $plan->bindings }, $literal->value); } if (my $lang = $literal->language) { push(@{ $plan->where }, "$termtable.language = ?"); push(@{ $plan->bindings }, $lang); } else { my $xs = Attean::IRI->new( value => 'http://www.w3.org/2001/XMLSchema#string' ); my $la = Attean::IRI->new( value => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString' ); my $xid = $self->_get_term_id($xs); my $lid = $self->_get_term_id($la); push(@{ $plan->where }, "$termtable.datatype_id IN (?, ?)"); push(@{ $plan->bindings }, $xid, $lid); } return $plan; } } } } } } } elsif ($algebra->isa('Attean::Algebra::BGP') and scalar(@{ $algebra->triples }) > 0) { my @vars = $algebra->in_scope_variables; my @triples = @{ $algebra->triples }; my @select; my @where_joins; my %seen_vars; my %source_table_for_var; my %blanks; my $tcounter = 0; my $bcounter = 0; my @tables; my %rename_mapping; my $rename_proj = sub { my $name = shift; if ($name =~ /[-._]|\W/) { my $old = $name; $name =~ s/_/__/g; $name =~ s/([-.]|\W)/_d/g; $name =~ s/([-.]|\W)/'_x' . sprintf('%02x', ord($1))/e; $rename_mapping{$old} = $name; } return $name; }; Carp::confess Dumper($active_graphs) unless (ref($active_graphs) eq 'ARRAY'); my @graph_ids = map { $self->_get_term_id($_) } @{ $active_graphs }; if (any { not defined($_) } @graph_ids) { return; } my @bind; my $graph = Attean::Variable->new(value => '___g'); $seen_vars{ $graph->value }++; my $graph_values = sprintf('(%s)', join(', ', ('?') x scalar(@graph_ids))); push(@bind, @graph_ids); my @where = ("t0.graph IN $graph_values"); foreach my $t (@triples) { my $table = 't' . $tcounter++; push(@tables, ['quad', $table]); my @vars; my $q = $t->as_quadpattern($graph); my @nodes = $q->values; foreach my $i (0 .. $#nodes) { my $node = $nodes[$i]; my $name = $pos_names[$i]; if ($node->does('Attean::API::Variable')) { my $var = $node; push(@vars, [$var, $name]); } elsif ($node->does('Attean::API::Blank')) { my $id = $node->value; unless (exists $blanks{$id}) { my $bname = sprintf('.%s_%d', 'blank', $bcounter++); $blanks{$id} = Attean::Variable->new(value => $bname); } my $var = $blanks{$id}; push(@vars, [$var, $name]); $seen_vars{ $var->value }++; } else { my $id = $self->_get_term_id($node); return unless defined($id); push(@where, sprintf('%s.%s = ?', $table, $name)); push(@bind, $id); } } foreach my $vdata (@vars) { my ($var, $name) = @$vdata; my $var_name = $rename_proj->( $var->value ); push(@select, [$table, $name, $var_name]) unless ($seen_vars{$var->value}++); if (my $tt = $source_table_for_var{ $var->value }) { push(@where_joins, ['=', $tt, [$table, $name]]); } else { $source_table_for_var{ $var->value } = [$table, $name]; } } } foreach my $w (@where_joins) { my ($op, $a, $b) = @$w; my ($as, $bs) = map { sprintf('%s.%s', @$_) } ($a, $b); push(@where, join(' ', $as, $op, $bs)); } return AtteanX::Store::DBI::Plan->new( store => $self, select => \@select, where => \@where, tables => \@tables, in_scope_variables => [@vars], rename_mapping => \%rename_mapping, bindings => \@bind, variables => \%source_table_for_var, ); } return; } =item C<< cost_for_plan( $plan ) >> Returns the estimated cost for a DBI-specific query plan, undef otherwise. =cut sub cost_for_plan { my $self = shift; my $plan = shift; if ($plan->isa('AtteanX::Store::DBI::Plan')) { return 1; # TODO: actually estimate cost here } return; } } package AtteanX::Store::DBI::Plan 0.012 { use Moo; use Type::Tiny::Role; use Types::Standard qw(HashRef ArrayRef InstanceOf Str); use namespace::clean; has store => (is => 'ro', isa => InstanceOf['AtteanX::Store::DBI'], required => 1); has rename_mapping => (is => 'ro', isa => HashRef[Str], default => sub { +{} }); has variables => (is => 'ro', isa => HashRef, required => 1); has bindings => (is => 'ro', isa => ArrayRef, required => 1); has select => (is => 'ro', isa => ArrayRef, required => 1); has where => (is => 'ro', isa => ArrayRef, required => 1); has tables => (is => 'ro', isa => ArrayRef[ArrayRef[Str]], required => 1); with 'Attean::API::BindingSubstitutionPlan', 'Attean::API::NullaryQueryTree'; sub plan_as_string { my $self = shift; my ($sql, @bind) = $self->sql(); return sprintf('DBI BGP { %s ← (%s) }', $sql, join(', ', @bind)); } sub sql { my $self = shift; my $bind = shift; my $store = $self->store; my $dbh = $store->dbh; my @bind = @{ $self->bindings }; my @where = @{ $self->where }; if ($bind) { foreach my $var ($bind->variables) { my $id = $store->_get_term_id($bind->value($var)); return unless defined($id); if (my $cdata = $self->variables->{ $var }) { my ($table, $col) = @$cdata; push(@where, sprintf("%s.%s = ?", $table, $col)); push(@bind, $id); } } } my @select = map { sprintf("%s.%s AS %s", map { $dbh->quote_identifier( $_ ) } @$_) } @{ $self->select }; unless (scalar(@select)) { push(@select, '1'); } my @sql; push(@sql, 'SELECT'); push(@sql, join(', ', @select)); push(@sql, 'FROM'); push(@sql, join(', ', map { join(' ', @$_) } @{ $self->tables })); if (scalar(@where)) { push(@sql, 'WHERE'); push(@sql, join(' AND ', map { "($_)" } @where)); } my $sql = join(" ", @sql); return ($sql, @bind); } sub substitute_impl { my $self = shift; my $model = shift; my ($sql, @bind) = $self->sql(@_); my $store = $self->store; my $dbh = $store->dbh; # warn "TODO: generatee SQL for BGP: $sql\n"; # warn "======================================================================\n"; # warn "$sql\n"; # warn "======================================================================\n"; my $vars = $self->in_scope_variables; my $sth = $dbh->prepare($sql); return sub { # warn "Generating impl by executing SQL"; my $rv = $sth->execute(@bind); unless ($rv) { warn '*** SQL error: ' . $sth->errstr; die; } my $sub = sub { # warn '=== Iterator invoked'; # use Data::Dumper; # warn Dumper($sql, \@bind); if (my $row = $sth->fetchrow_hashref) { # warn '@@@ Iterator got row'; # warn Dumper($row); my %bindings; foreach my $k (@$vars) { my $key = $self->rename_mapping->{$k} // $k; my $term = $store->_get_term($row->{$key}); $bindings{$k} = $term; } my $r = Attean::Result->new( bindings => \%bindings ); return $r; } else { # warn '^^^ Reached end-of-iterator' } return; }; return Attean::CodeIterator->new( generator => $sub, item_type => 'Attean::API::Result', variables => $vars ); }; } } 1; __END__ =back =head1 BUGS Please report any bugs or feature requests to through the GitHub web interface at L. =head1 AUTHOR Gregory Todd Williams C<< >> =head1 COPYRIGHT Copyright (c) 2014--2020 Gregory Todd Williams. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut AtteanX-Store-DBI-0.003/lib/Test/AtteanX/000755 000765 000024 00000000000 14764061652 017701 5ustar00gregstaff000000 000000 AtteanX-Store-DBI-0.003/lib/Test/AtteanX/Store/000755 000765 000024 00000000000 14764061652 020775 5ustar00gregstaff000000 000000 AtteanX-Store-DBI-0.003/lib/Test/AtteanX/Store/PaxHeader/DBI.pm000644 000765 000024 00000000225 14763417346 023705 xustar00gregstaff000000 000000 30 mtime=1741561574.496052784 64 LIBARCHIVE.xattr.com.apple.TextEncoding=VVRGLTg7MTM0MjE3OTg0 55 SCHILY.xattr.com.apple.TextEncoding=UTF-8;134217984 AtteanX-Store-DBI-0.003/lib/Test/AtteanX/Store/DBI.pm000644 000765 000024 00000012354 14763417346 021742 0ustar00gregstaff000000 000000 package Test::AtteanX::Store::DBI; use utf8; use v5.14; use warnings; use Data::Dumper; use Test::Roo::Role; use Test::Moose; use Attean; use Attean::RDF; requires 'create_store'; # create_store( quads => \@triples ) sub test_quads { my @q; for my $i (0 .. 5) { push(@q, quad(iri('s'), iri('p'), literal($i), iri('g'))); push(@q, quad(iri('s'), iri('p'), blank("b$i"), iri('g'))); } my @strings; push(@strings, literal('Hi')); push(@strings, langliteral('Hello', 'en')); push(@strings, langliteral('火星', 'ja')); push(@strings, dtliteral(787, 'http://www.w3.org/2001/XMLSchema#integer')); foreach my $s (@strings) { push(@q, quad(iri('s'), iri('str'), $s, iri('strings'))); } return \@q; } test 'ISLITERAL type constraint SARG' => sub { my $self = shift; my $store = $self->create_store(quads => $self->test_quads); my $model = Attean::QuadModel->new( store => $store ); my $dbh = $store->dbh; my $typecol = $dbh->quote_identifier('type'); my $algebra = Attean->get_parser('SPARQL')->parse('SELECT * WHERE { ?s ?p ?o FILTER ISLITERAL(?o) }'); my $default_graphs = [iri('g')]; my $planner = Attean::IDPQueryPlanner->new(); my $plan = $planner->plan_for_algebra($algebra, $model, $default_graphs); isa_ok($plan, 'AtteanX::Store::DBI::Plan'); my ($sql, @bind) = $plan->sql; like($sql, qr, 'generated SQL'); is($bind[-1], 'blank', 'bound values'); }; test 'ISLITERAL type constraint SARG' => sub { my $self = shift; my $store = $self->create_store(quads => $self->test_quads); my $model = Attean::QuadModel->new( store => $store ); my $dbh = $store->dbh; my $typecol = $dbh->quote_identifier('type'); my $algebra = Attean->get_parser('SPARQL')->parse('SELECT * WHERE { ?s ?p ?o FILTER ISLITERAL(?o) }'); my $default_graphs = [iri('strings')]; my $planner = Attean::IDPQueryPlanner->new(); my $plan = $planner->plan_for_algebra($algebra, $model, $default_graphs); isa_ok($plan, 'AtteanX::Store::DBI::Plan'); my ($sql, @bind) = $plan->sql; like($sql, qr, 'generated SQL'); is($bind[-1], 'iri'); }; test 'STRSTARTS' => sub { local($Data::Dumper::Indent) = 0; my $self = shift; my $store = $self->create_store(quads => $self->test_quads); my $model = Attean::QuadModel->new( store => $store ); subtest 'STR()' => sub { my $algebra = Attean->get_parser('SPARQL')->parse('SELECT * WHERE { ?s ?p ?o FILTER STRSTARTS(STR(?o), "H") }'); my $default_graphs = [iri('strings')]; my $planner = Attean::IDPQueryPlanner->new(); my $plan = $planner->plan_for_algebra($algebra, $model, $default_graphs); my @rows = $plan->evaluate($model)->elements; is(scalar(@rows), 2, 'result count'); foreach my $r (@rows) { like($r->value('o')->value, qr/^H/, 'literal value'); } }; subtest 'xsd:string' => sub { my $algebra = Attean->get_parser('SPARQL')->parse('SELECT * WHERE { ?s ?p ?o FILTER STRSTARTS(?o, "H") }'); my $default_graphs = [iri('strings')]; my $planner = Attean::IDPQueryPlanner->new(); my $plan = $planner->plan_for_algebra($algebra, $model, $default_graphs); isa_ok($plan, 'AtteanX::Store::DBI::Plan'); my $iter = $plan->evaluate($model); my @rows = $iter->elements; is(scalar(@rows), 2, 'result count: ' . Dumper([$plan->sql])); foreach my $r (@rows) { like($r->value('o')->value, qr/^H/, 'literal value'); } }; subtest 'language string' => sub { my $algebra = Attean->get_parser('SPARQL')->parse('SELECT * WHERE { ?s ?p ?o FILTER STRSTARTS(?o, "H"@en) }'); my $default_graphs = [iri('strings')]; my $planner = Attean::IDPQueryPlanner->new(); my $plan = $planner->plan_for_algebra($algebra, $model, $default_graphs); isa_ok($plan, 'AtteanX::Store::DBI::Plan'); my @rows = $plan->evaluate($model)->elements; is(scalar(@rows), 1, 'result count'); is($rows[0]->value('o')->value, 'Hello', 'literal value'); }; }; 1; AtteanX-Store-DBI-0.003/xt/pod.t000644 000765 000024 00000000233 11760736733 016252 0ustar00gregstaff000000 000000 use strict; use warnings; use Test::More; eval "use Test::Pod 1.14"; plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; all_pod_files_ok(); AtteanX-Store-DBI-0.003/xt/PaxHeader/dawg11-sqlite.t000755 000765 000024 00000000225 13761616707 022031 xustar00gregstaff000000 000000 30 mtime=1606884807.223855167 64 LIBARCHIVE.xattr.com.apple.TextEncoding=VVRGLTg7MTM0MjE3OTg0 55 SCHILY.xattr.com.apple.TextEncoding=UTF-8;134217984 AtteanX-Store-DBI-0.003/xt/dawg11-sqlite.t000755 000765 000024 00000003240 13761616707 020060 0ustar00gregstaff000000 000000 #!/usr/bin/perl use utf8; use v5.14; use strict; use warnings; no warnings 'redefine'; no warnings 'once'; binmode(\*STDOUT, ':encoding(UTF-8)'); binmode(\*STDERR, ':encoding(UTF-8)'); use autodie; use Test::Roo; use File::Slurp; use File::Temp qw(tempfile); use List::MoreUtils qw(all); use DBIx::MultiStatementDo; use Types::Standard qw(Str ArrayRef); use Class::Method::Modifiers; use AtteanX::Store::DBI; with 'Test::Attean::SPARQLSuite'; has 'test_files' => (is => 'rw', isa => ArrayRef, default => sub { [] }); has 'file' => (is => 'rw', isa => Str); my %args; while (defined(my $opt = shift)) { if ($opt eq '-v') { $args{debug}++; } else { $args{pattern} = $opt; } } around 'setup' => sub { my $orig = shift; my $self = shift; (undef, my $filename) = tempfile(); # warn $filename; push(@{ $self->test_files }, $filename); $self->file($filename); my @connect = AtteanX::Store::DBI->dbi_connect_args( 'sqlite', database => $filename, ); my $dbh = DBI->connect(@connect); my $store = Attean->get_store('DBI')->new( dbh => $dbh ); eval { $store->init(); }; if ($@) { plan skip_all => "No schema files available for SQLite"; exit(0); } return $orig->($self, @_); }; after 'teardown' => sub { my $self = shift; unlink($self->file); }; sub test_model { my $self = shift; my @connect = AtteanX::Store::DBI->dbi_connect_args('sqlite', database => $self->file); my $dbh = DBI->connect(@connect); my $store = Attean->get_store('DBI')->new( dbh => $dbh ); foreach my $g ($store->get_graphs->elements) { $store->drop_graph($g); } my $model = Attean::MutableQuadModel->new( store => $store ); return $model; } run_me(\%args); done_testing; AtteanX-Store-DBI-0.003/xt/dawg11-mysql.t000755 000765 000024 00000002515 12673602251 017716 0ustar00gregstaff000000 000000 #!/usr/bin/perl use utf8; use v5.14; use strict; use warnings; no warnings 'redefine'; no warnings 'once'; binmode(\*STDOUT, ':encoding(UTF-8)'); binmode(\*STDERR, ':encoding(UTF-8)'); use autodie; use Test::Roo; use List::MoreUtils qw(all); use AtteanX::Store::DBI; with 'Test::Attean::SPARQLSuite'; my %args; while (defined(my $opt = shift)) { if ($opt eq '-v') { $args{debug}++; } else { $args{pattern} = $opt; } } sub test_model { unless (all { exists $ENV{$_} } qw(ATTEAN_STORE_MYSQL_DATABASE ATTEAN_STORE_MYSQL_HOST ATTEAN_STORE_MYSQL_USER ATTEAN_STORE_MYSQL_PASSWORD)) { plan skip_all => "Set the MySQL environment variables to run these tests (ATTEAN_STORE_MYSQL_DATABASE, ATTEAN_STORE_MYSQL_HOST, ATTEAN_STORE_MYSQL_PORT, ATTEAN_STORE_MYSQL_USER, ATTEAN_STORE_MYSQL_PASSWORD)"; exit(0); } my @connect = AtteanX::Store::DBI->dbi_connect_args( 'mysql', database => $ENV{ATTEAN_STORE_MYSQL_DATABASE}, host => $ENV{ATTEAN_STORE_MYSQL_HOST}, user => $ENV{ATTEAN_STORE_MYSQL_USER}, password => $ENV{ATTEAN_STORE_MYSQL_PASSWORD}, ); my $dbh = DBI->connect(@connect); my $store = Attean->get_store('DBI')->new( dbh => $dbh ); foreach my $g ($store->get_graphs->elements) { $store->drop_graph($g); } my $model = Attean::MutableQuadModel->new( store => $store ); return $model; } run_me(\%args); done_testing; AtteanX-Store-DBI-0.003/xt/dawg11-postgresql.t000755 000765 000024 00000002460 12673602245 020756 0ustar00gregstaff000000 000000 #!/usr/bin/perl use utf8; use v5.14; use strict; use warnings; no warnings 'redefine'; no warnings 'once'; binmode(\*STDOUT, ':encoding(UTF-8)'); binmode(\*STDERR, ':encoding(UTF-8)'); use autodie; use Test::Roo; use List::MoreUtils qw(all); use AtteanX::Store::DBI; with 'Test::Attean::SPARQLSuite'; my %args; while (defined(my $opt = shift)) { if ($opt eq '-v') { $args{debug}++; } else { $args{pattern} = $opt; } } sub test_model { unless (all { exists $ENV{$_} } qw(ATTEAN_STORE_PG_DATABASE ATTEAN_STORE_PG_HOST ATTEAN_STORE_PG_USER ATTEAN_STORE_PG_PASSWORD)) { plan skip_all => "Set the PostgreSQL environment variables to run these tests (ATTEAN_STORE_PG_DATABASE, ATTEAN_STORE_PG_HOST, ATTEAN_STORE_PG_PORT, ATTEAN_STORE_PG_USER, ATTEAN_STORE_PG_PASSWORD)"; exit(0); } my @connect = AtteanX::Store::DBI->dbi_connect_args( 'postgresql', database => $ENV{ATTEAN_STORE_PG_DATABASE}, host => $ENV{ATTEAN_STORE_PG_HOST}, user => $ENV{ATTEAN_STORE_PG_USER}, password => $ENV{ATTEAN_STORE_PG_PASSWORD}, ); my $dbh = DBI->connect(@connect); my $store = Attean->get_store('DBI')->new( dbh => $dbh ); foreach my $g ($store->get_graphs->elements) { $store->drop_graph($g); } my $model = Attean::MutableQuadModel->new( store => $store ); return $model; } run_me(\%args); done_testing; AtteanX-Store-DBI-0.003/xt/pod-coverage.t000644 000765 000024 00000000777 12643235470 020051 0ustar00gregstaff000000 000000 use strict; use warnings; use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; use Module::Load::Conditional qw[can_load]; my @modules = all_modules(); foreach my $mod (@modules) { next if ($mod =~ /^Test::/); if (can_load( modules => { $mod => 0 } )) { pod_coverage_ok($mod, { also_private => [ qr{^[A-Z][A-Z0-9_]*$} ] }); } else { note("Ignoring $mod for POD coverage tests (failed to load)"); } } done_testing(); AtteanX-Store-DBI-0.003/t/PaxHeader/store-dbi-postgresql.t000644 000765 000024 00000000225 14763417561 023344 xustar00gregstaff000000 000000 30 mtime=1741561713.710491325 64 LIBARCHIVE.xattr.com.apple.TextEncoding=VVRGLTg7MTM0MjE3OTg0 55 SCHILY.xattr.com.apple.TextEncoding=UTF-8;134217984 AtteanX-Store-DBI-0.003/t/store-dbi-postgresql.t000644 000765 000024 00000005741 14763417561 021403 0ustar00gregstaff000000 000000 use Test::Roo; use Test::Exception; use List::MoreUtils qw(all); use v5.14; use warnings; no warnings 'redefine'; use Attean; use Attean::RDF; use AtteanX::Store::DBI; sub create_store { my $self = shift; my %args = @_; my $quads = $args{quads} // []; my @connect = AtteanX::Store::DBI->dbi_connect_args( 'postgresql', database => $ENV{ATTEAN_STORE_PG_DATABASE}, host => $ENV{ATTEAN_STORE_PG_HOST}, user => $ENV{ATTEAN_STORE_PG_USER}, password => $ENV{ATTEAN_STORE_PG_PASSWORD}, ); my $dbh = DBI->connect(@connect); my $store = Attean->get_store('DBI')->new( dbh => $dbh ); foreach my $g ($store->get_graphs->elements) { $store->drop_graph($g); } foreach my $q (@$quads) { $store->add_quad($q); } return $store; } unless (all { exists $ENV{$_} } qw(ATTEAN_STORE_PG_DATABASE ATTEAN_STORE_PG_HOST ATTEAN_STORE_PG_USER ATTEAN_STORE_PG_PASSWORD)) { plan skip_all => "Set the MySQL environment variables to run these tests (ATTEAN_STORE_PG_DATABASE, ATTEAN_STORE_PG_HOST, ATTEAN_STORE_PG_USER, ATTEAN_STORE_PG_PASSWORD)"; } test 'Pg STRSTARTS SARG with string literal' => sub { my $self = shift; my $store = $self->create_store(quads => $self->test_quads); my $model = Attean::QuadModel->new( store => $store ); my $algebra = Attean->get_parser('SPARQL')->parse('SELECT * WHERE { ?s ?p ?o FILTER STRSTARTS(?o, "foo") }'); my $default_graphs = [iri('g')]; my $planner = Attean::IDPQueryPlanner->new(); my $plan = $planner->plan_for_algebra($algebra, $model, $default_graphs); isa_ok($plan, 'AtteanX::Store::DBI::Plan'); my ($sql, @bind) = $plan->sql; like($sql, qr#SELECT "t0"."subject" AS "s", "t0"."predicate" AS "p", "t0"."object" AS "o" FROM quad t0, term (\S+) WHERE [(]t0.graph IN [(][?][)][)] AND [(]"t0"."object" = \1.term_id[)] AND [(]\1."type" = [?][)] AND [(]STRPOS[(]\1.value, [?][)] = [?][)] AND [(]\1.datatype_id IN [(][?], [?][)][)]#, 'generated SQL'); is_deeply([splice(@bind, 1, 3)], ['literal', 'foo', 1], 'bound values'); }; test 'Pg STRSTARTS SARG with language literal' => sub { my $self = shift; my $store = $self->create_store(quads => $self->test_quads); my $model = Attean::QuadModel->new( store => $store ); my $algebra = Attean->get_parser('SPARQL')->parse('SELECT * WHERE { ?s ?p ?o FILTER STRSTARTS(?o, "foo"@en) }'); my $default_graphs = [iri('g')]; my $planner = Attean::IDPQueryPlanner->new(); my $plan = $planner->plan_for_algebra($algebra, $model, $default_graphs); isa_ok($plan, 'AtteanX::Store::DBI::Plan'); my ($sql, @bind) = $plan->sql; like($sql, qr#SELECT "t0"."subject" AS "s", "t0"."predicate" AS "p", "t0"."object" AS "o" FROM quad t0, term (\S+) WHERE [(]t0.graph IN [(][?][)][)] AND [(]"t0"."object" = \1.term_id[)] AND [(]\1."type" = [?][)] AND [(]STRPOS[(]\1.value, [?][)] = [?][)] AND [(]\1.language = [?][)]#, 'generated SQL'); is_deeply([splice(@bind, 1)], ['literal', 'foo', 1, 'en'], 'bound values'); }; with 'Test::Attean::QuadStore', 'Test::Attean::MutableQuadStore'; with 'Test::AtteanX::Store::DBI'; run_me; done_testing(); AtteanX-Store-DBI-0.003/t/PaxHeader/store-dbi-sqlite.t000644 000765 000024 00000000225 14763417574 022446 xustar00gregstaff000000 000000 30 mtime=1741561724.739786652 64 LIBARCHIVE.xattr.com.apple.TextEncoding=VVRGLTg7MTM0MjE3OTg0 55 SCHILY.xattr.com.apple.TextEncoding=UTF-8;134217984 AtteanX-Store-DBI-0.003/t/store-dbi-sqlite.t000644 000765 000024 00000005444 14763417574 020505 0ustar00gregstaff000000 000000 use Test::Roo; use Test::Exception; use List::MoreUtils qw(all); use File::Temp qw(tempfile); use DBIx::MultiStatementDo; use File::Slurp; use v5.14; use warnings; no warnings 'redefine'; use Attean; use Attean::RDF; use AtteanX::Store::DBI; sub create_store { my $self = shift; my %args = @_; my $quads = $args{quads} // []; (undef, my $filename) = tempfile(); my @connect = AtteanX::Store::DBI->dbi_connect_args( 'sqlite', database => $filename, ); my $dbh = DBI->connect(@connect); my $batch = DBIx::MultiStatementDo->new( dbh => $dbh ); my $store = Attean->get_store('DBI')->new( dbh => $dbh ); if (my $file = $store->create_schema_file) { my $sql = read_file($file); $batch->do($sql); } else { plan skip_all => "No schema files available for SQLite"; exit(0); } foreach my $q (@$quads) { $store->add_quad($q); } return $store; } test 'SQLite STRSTARTS SARG with string literal' => sub { my $self = shift; my $store = $self->create_store(quads => $self->test_quads); my $model = Attean::QuadModel->new( store => $store ); my $algebra = Attean->get_parser('SPARQL')->parse('SELECT * WHERE { ?s ?p ?o FILTER STRSTARTS(?o, "foo") }'); my $default_graphs = [iri('g')]; my $planner = Attean::IDPQueryPlanner->new(); my $plan = $planner->plan_for_algebra($algebra, $model, $default_graphs); isa_ok($plan, 'AtteanX::Store::DBI::Plan'); my ($sql, @bind) = $plan->sql; like($sql, qr#SELECT "t0"."subject" AS "s", "t0"."predicate" AS "p", "t0"."object" AS "o" FROM quad t0, term (\S+) WHERE [(]t0.graph IN [(][?][)][)] AND [(]"t0"."object" = \1.term_id[)] AND [(]\1."type" = [?][)] AND [(]INSTR[(]\1.value, [?][)] = 1[)] AND [(]\1.datatype_id IN [(][?], [?][)][)]#, 'generated SQL'); is_deeply([splice(@bind, 1, 2)], ['literal', 'foo'], 'bound values'); }; test 'SQLite STRSTARTS SARG with language literal' => sub { my $self = shift; my $store = $self->create_store(quads => $self->test_quads); my $model = Attean::QuadModel->new( store => $store ); my $algebra = Attean->get_parser('SPARQL')->parse('SELECT * WHERE { ?s ?p ?o FILTER STRSTARTS(?o, "foo"@en) }'); my $default_graphs = [iri('g')]; my $planner = Attean::IDPQueryPlanner->new(); my $plan = $planner->plan_for_algebra($algebra, $model, $default_graphs); isa_ok($plan, 'AtteanX::Store::DBI::Plan'); my ($sql, @bind) = $plan->sql; like($sql, qr#SELECT "t0"."subject" AS "s", "t0"."predicate" AS "p", "t0"."object" AS "o" FROM quad t0, term (\S+) WHERE [(]t0.graph IN [(][?][)][)] AND [(]"t0"."object" = \1.term_id[)] AND [(]\1."type" = [?][)] AND [(]INSTR[(]\1.value, [?][)] = 1[)] AND [(]\1.language = [?][)]#, 'generated SQL'); is_deeply([splice(@bind, 1)], ['literal', 'foo', 'en'], 'bound values'); }; with 'Test::Attean::QuadStore', 'Test::Attean::MutableQuadStore'; with 'Test::AtteanX::Store::DBI'; run_me; done_testing(); AtteanX-Store-DBI-0.003/t/PaxHeader/store-dbi-mysql.t000644 000765 000024 00000000224 14763417563 022307 xustar00gregstaff000000 000000 29 mtime=1741561715.36747961 64 LIBARCHIVE.xattr.com.apple.TextEncoding=VVRGLTg7MTM0MjE3OTg0 55 SCHILY.xattr.com.apple.TextEncoding=UTF-8;134217984 AtteanX-Store-DBI-0.003/t/store-dbi-mysql.t000644 000765 000024 00000006040 14763417563 020340 0ustar00gregstaff000000 000000 use Test::Roo; use Test::Exception; use List::MoreUtils qw(all); use v5.14; use warnings; no warnings 'redefine'; use Attean; use Attean::RDF; use AtteanX::Store::DBI; sub create_store { my $self = shift; my %args = @_; my $quads = $args{quads} // []; my @connect = AtteanX::Store::DBI->dbi_connect_args( 'mysql', database => $ENV{ATTEAN_STORE_MYSQL_DATABASE}, host => $ENV{ATTEAN_STORE_MYSQL_HOST}, user => $ENV{ATTEAN_STORE_MYSQL_USER}, password => $ENV{ATTEAN_STORE_MYSQL_PASSWORD}, ); my $dbh = DBI->connect(@connect); my $store = Attean->get_store('DBI')->new( dbh => $dbh ); foreach my $g ($store->get_graphs->elements) { $store->drop_graph($g); } foreach my $q (@$quads) { $store->add_quad($q); } return $store; } unless (all { exists $ENV{$_} } qw(ATTEAN_STORE_MYSQL_DATABASE ATTEAN_STORE_MYSQL_HOST ATTEAN_STORE_MYSQL_USER ATTEAN_STORE_MYSQL_PASSWORD)) { plan skip_all => "Set the MySQL environment variables to run these tests (ATTEAN_STORE_MYSQL_DATABASE, ATTEAN_STORE_MYSQL_HOST, ATTEAN_STORE_MYSQL_PORT, ATTEAN_STORE_MYSQL_USER, ATTEAN_STORE_MYSQL_PASSWORD)"; } test 'MySQL STRSTARTS SARG with string literal' => sub { my $self = shift; my $store = $self->create_store(quads => $self->test_quads); my $model = Attean::QuadModel->new( store => $store ); my $algebra = Attean->get_parser('SPARQL')->parse('SELECT * WHERE { ?s ?p ?o FILTER STRSTARTS(?o, "foo") }'); my $default_graphs = [iri('g')]; my $planner = Attean::IDPQueryPlanner->new(); my $plan = $planner->plan_for_algebra($algebra, $model, $default_graphs); isa_ok($plan, 'AtteanX::Store::DBI::Plan'); my ($sql, @bind) = $plan->sql; like($sql, qr#SELECT `t0`.`subject` AS `s`, `t0`.`predicate` AS `p`, `t0`.`object` AS `o` FROM quad t0, term (\S+) WHERE [(]t0.graph IN [(][?][)][)] AND [(]`t0`.`object` = \1.term_id[)] AND [(]\1.`type` = [?][)] AND [(]LOCATE[(][?], \1.value[)] = [?][)] AND [(]\1.datatype_id IN [(][?], [?][)][)]#, 'generated SQL'); is_deeply([splice(@bind, 1, 3)], ['literal', 'foo', 1], 'bound values'); }; test 'MySQL STRSTARTS SARG with language literal' => sub { my $self = shift; my $store = $self->create_store(quads => $self->test_quads); my $model = Attean::QuadModel->new( store => $store ); my $algebra = Attean->get_parser('SPARQL')->parse('SELECT * WHERE { ?s ?p ?o FILTER STRSTARTS(?o, "foo"@en) }'); my $default_graphs = [iri('g')]; my $planner = Attean::IDPQueryPlanner->new(); my $plan = $planner->plan_for_algebra($algebra, $model, $default_graphs); isa_ok($plan, 'AtteanX::Store::DBI::Plan'); my ($sql, @bind) = $plan->sql; like($sql, qr#SELECT `t0`.`subject` AS `s`, `t0`.`predicate` AS `p`, `t0`.`object` AS `o` FROM quad t0, term (\S+) WHERE [(]t0.graph IN [(][?][)][)] AND [(]`t0`.`object` = \1.term_id[)] AND [(]\1.`type` = [?][)] AND [(]LOCATE[(][?], \1.value[)] = [?][)] AND [(]\1.language = [?][)]#, 'generated SQL'); is_deeply([splice(@bind, 1)], ['literal', 'foo', 1, 'en'], 'bound values'); }; with 'Test::Attean::QuadStore', 'Test::Attean::MutableQuadStore'; with 'Test::AtteanX::Store::DBI'; run_me; done_testing(); AtteanX-Store-DBI-0.003/meta/PaxHeader/changes.ttl000644 000765 000024 00000000225 14764061552 021702 xustar00gregstaff000000 000000 30 mtime=1741710186.576351115 64 LIBARCHIVE.xattr.com.apple.TextEncoding=VVRGLTg7MTM0MjE3OTg0 55 SCHILY.xattr.com.apple.TextEncoding=UTF-8;134217984 AtteanX-Store-DBI-0.003/meta/changes.ttl000644 000765 000024 00000004014 14764061552 017731 0ustar00gregstaff000000 000000 # -*-n3-*- @prefix : . @prefix dc: . @prefix dcs: . @prefix foaf: . @prefix rdfs: . @prefix xsd: . @prefix dcterms: . @prefix doap: . @prefix my: . <> dc:title "Changes for AtteanX::Store::DBI" ; dc:subject my:project ; dc:creator my:developer ; dc:description "Changes for AtteanX::Store::DBI" ; . my:project a :Project ; :name "AtteanX::Store::DBI" ; :shortdesc "A DBI-backed quadstore for Attean" ; :programming-language "Perl" ; :created "2016-03-14"^^xsd:date ; :maintainer my:developer ; :homepage ; :bug-database ; doap:download-page ; doap:download-mirror ; :release my:v_0-001 , my:v_0-002 , my:v_0-003 ; . my:v_0-003 a :Version ; dc:issued "2025-03-11"^^xsd:date ; :revision "0.003" ; dcterms:replaces my:v_0-002 ; dcs:changeset [ dcs:item [ a dcs:Update ; rdfs:label "Fix developer tests to silence warnings." ] ] . my:v_0-002 a :Version ; dc:issued "2020-12-12"^^xsd:date ; :revision "0.002" ; dcterms:replaces my:v_0-001 ; dcs:changeset [ dcs:item [ a dcs:Update ; rdfs:label "Add DBD::SQLite as a test prereq (#6)." ] , [ a dcs:Update ; rdfs:label "Remove mistakenly added LICENSE file (#5)." ] , [ a dcs:Update ; rdfs:label "Remove Math::Cartesian::Product from prereq list (#4)." ] , [ a dcs:Update ; rdfs:label "Update copyright years (#3)." ] ] . my:v_0-001 a :Version ; dc:issued "2020-12-02"^^xsd:date ; :revision "0.001" ; dcs:changeset [ dcs:item [ a dcs:Addition ; rdfs:label "Initial release." ] ] . AtteanX-Store-DBI-0.003/bin/PaxHeader/attean_dbi000755 000765 000024 00000000422 13133671556 021406 xustar00gregstaff000000 000000 64 LIBARCHIVE.xattr.com.apple.TextEncoding=VVRGLTg7MTM0MjE3OTg0 55 SCHILY.xattr.com.apple.TextEncoding=UTF-8;134217984 85 LIBARCHIVE.xattr.com.apple.FinderInfo=VEVYVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 70 SCHILY.xattr.com.apple.FinderInfo=TEXT AtteanX-Store-DBI-0.003/bin/attean_dbi000755 000765 000024 00000004300 13133671556 017434 0ustar00gregstaff000000 000000 #!/usr/bin/env perl use v5.14; use warnings; use autodie; use File::Slurp; use Attean; use AtteanX::Store::DBI; use DBI; use DBIx::MultiStatementDo; use Getopt::Long qw(:config no_ignore_case); my @types = AtteanX::Store::DBI->available_database_types; my %types = map { $_ => 1 } @types; if (scalar(@types) == 0) { warn "No database types are available for use with Attean."; exit(0); } my $COMMANDS_STRING = join("\n", map { " $_" } qw(init drop)); my $TYPES_STRING = join("\n", map { " $_" } @types); if (scalar(@ARGV) < 1) { print STDERR <<"END"; Usage: $0 COMMAND DATATYPE-TYPE [-h HOST] [-P PORT] [-u USER] [-p PASSWORD] DATABASE-NAME COMMAND must be one of: $COMMANDS_STRING DATABASE-TYPE must be one of: $TYPES_STRING END exit(0); } my $verbose = 0; my $dryrun = 0; my $host; my $port; my $user; my $password; my %args; my $result = GetOptions( "verbose" => \$verbose, 'n' => \$dryrun, "host=s" => \$args{host}, "port|P=s" => \$args{port}, "user=s" => \$args{user}, "password|p=s" => \$args{password}, ); my $command = shift; die "Unrecoognized command '$command'. Must be one of:$COMMANDS_STRING\n\n" unless ($command =~ /^(init|drop)$/); my $type = shift; die "No database type given. Must be one of:\n\n$TYPES_STRING\n\n" unless (defined($type) and length($type)); die "Unrecoognized database type '$type'. Must be one of:\n\n$TYPES_STRING\n\n" unless (exists $types{$type}); $args{database} = shift || die "No database name given.\n"; my @connect = AtteanX::Store::DBI->dbi_connect_args($type, %args); my $dbh = DBI->connect(@connect); my $store = AtteanX::Store::DBI->new( dbh => $dbh ); my $batch = DBIx::MultiStatementDo->new( dbh => $dbh ); if ($command eq 'init') { if (my $file = $store->create_schema_file) { my $sql = read_file($file); if ($dryrun) { print "$sql\n"; } else { $batch->do($sql); $store->initialize_version; } } else { warn "No schema file available for this database.\n"; exit(1); } } elsif ($command eq 'drop') { if (my $file = $store->drop_schema_file) { my $sql = read_file($file); if ($dryrun) { print "$sql\n"; } else { $batch->do($sql); } } else { warn "No schema file available for this database.\n"; exit(1); } } AtteanX-Store-DBI-0.003/inc/Module/000755 000765 000024 00000000000 14764061652 016646 5ustar00gregstaff000000 000000 AtteanX-Store-DBI-0.003/inc/Module/Install/000755 000765 000024 00000000000 14764061652 020254 5ustar00gregstaff000000 000000 AtteanX-Store-DBI-0.003/inc/Module/Install.pm000644 000765 000024 00000027145 14764061647 020627 0ustar00gregstaff000000 000000 #line 1 package Module::Install; # For any maintainers: # The load order for Module::Install is a bit magic. # It goes something like this... # # IF ( host has Module::Install installed, creating author mode ) { # 1. Makefile.PL calls "use inc::Module::Install" # 2. $INC{inc/Module/Install.pm} set to installed version of inc::Module::Install # 3. The installed version of inc::Module::Install loads # 4. inc::Module::Install calls "require Module::Install" # 5. The ./inc/ version of Module::Install loads # } ELSE { # 1. Makefile.PL calls "use inc::Module::Install" # 2. $INC{inc/Module/Install.pm} set to ./inc/ version of Module::Install # 3. The ./inc/ version of Module::Install loads # } use 5.006; use strict 'vars'; use Cwd (); use File::Find (); use File::Path (); use vars qw{$VERSION $MAIN}; BEGIN { # All Module::Install core packages now require synchronised versions. # This will be used to ensure we don't accidentally load old or # different versions of modules. # This is not enforced yet, but will be some time in the next few # releases once we can make sure it won't clash with custom # Module::Install extensions. $VERSION = '1.21'; # Storage for the pseudo-singleton $MAIN = undef; *inc::Module::Install::VERSION = *VERSION; @inc::Module::Install::ISA = __PACKAGE__; } sub import { my $class = shift; my $self = $class->new(@_); my $who = $self->_caller; #------------------------------------------------------------- # all of the following checks should be included in import(), # to allow "eval 'require Module::Install; 1' to test # installation of Module::Install. (RT #51267) #------------------------------------------------------------- # Whether or not inc::Module::Install is actually loaded, the # $INC{inc/Module/Install.pm} is what will still get set as long as # the caller loaded module this in the documented manner. # If not set, the caller may NOT have loaded the bundled version, and thus # they may not have a MI version that works with the Makefile.PL. This would # result in false errors or unexpected behaviour. And we don't want that. my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm'; unless ( $INC{$file} ) { die <<"END_DIE" } Please invoke ${\__PACKAGE__} with: use inc::${\__PACKAGE__}; not: use ${\__PACKAGE__}; END_DIE # This reportedly fixes a rare Win32 UTC file time issue, but # as this is a non-cross-platform XS module not in the core, # we shouldn't really depend on it. See RT #24194 for detail. # (Also, this module only supports Perl 5.6 and above). eval "use Win32::UTCFileTime" if $^O eq 'MSWin32' && $] >= 5.006; # If the script that is loading Module::Install is from the future, # then make will detect this and cause it to re-run over and over # again. This is bad. Rather than taking action to touch it (which # is unreliable on some platforms and requires write permissions) # for now we should catch this and refuse to run. if ( -f $0 ) { my $s = (stat($0))[9]; # If the modification time is only slightly in the future, # sleep briefly to remove the problem. my $a = $s - time; if ( $a > 0 and $a < 5 ) { sleep 5 } # Too far in the future, throw an error. my $t = time; if ( $s > $t ) { die <<"END_DIE" } Your installer $0 has a modification time in the future ($s > $t). This is known to create infinite loops in make. Please correct this, then run $0 again. END_DIE } # Build.PL was formerly supported, but no longer is due to excessive # difficulty in implementing every single feature twice. if ( $0 =~ /Build.PL$/i ) { die <<"END_DIE" } Module::Install no longer supports Build.PL. It was impossible to maintain duel backends, and has been deprecated. Please remove all Build.PL files and only use the Makefile.PL installer. END_DIE #------------------------------------------------------------- # To save some more typing in Module::Install installers, every... # use inc::Module::Install # ...also acts as an implicit use strict. $^H |= strict::bits(qw(refs subs vars)); #------------------------------------------------------------- unless ( -f $self->{file} ) { foreach my $key (keys %INC) { delete $INC{$key} if $key =~ /Module\/Install/; } local $^W; require "$self->{path}/$self->{dispatch}.pm"; File::Path::mkpath("$self->{prefix}/$self->{author}"); $self->{admin} = "$self->{name}::$self->{dispatch}"->new( _top => $self ); $self->{admin}->init; @_ = ($class, _self => $self); goto &{"$self->{name}::import"}; } local $^W; *{"${who}::AUTOLOAD"} = $self->autoload; $self->preload; # Unregister loader and worker packages so subdirs can use them again delete $INC{'inc/Module/Install.pm'}; delete $INC{'Module/Install.pm'}; # Save to the singleton $MAIN = $self; return 1; } sub autoload { my $self = shift; my $who = $self->_caller; my $cwd = Cwd::getcwd(); my $sym = "${who}::AUTOLOAD"; $sym->{$cwd} = sub { my $pwd = Cwd::getcwd(); if ( my $code = $sym->{$pwd} ) { # Delegate back to parent dirs goto &$code unless $cwd eq $pwd; } unless ($$sym =~ s/([^:]+)$//) { # XXX: it looks like we can't retrieve the missing function # via $$sym (usually $main::AUTOLOAD) in this case. # I'm still wondering if we should slurp Makefile.PL to # get some context or not ... my ($package, $file, $line) = caller; die <<"EOT"; Unknown function is found at $file line $line. Execution of $file aborted due to runtime errors. If you're a contributor to a project, you may need to install some Module::Install extensions from CPAN (or other repository). If you're a user of a module, please contact the author. EOT } my $method = $1; if ( uc($method) eq $method ) { # Do nothing return; } elsif ( $method =~ /^_/ and $self->can($method) ) { # Dispatch to the root M:I class return $self->$method(@_); } # Dispatch to the appropriate plugin unshift @_, ( $self, $1 ); goto &{$self->can('call')}; }; } sub preload { my $self = shift; unless ( $self->{extensions} ) { $self->load_extensions( "$self->{prefix}/$self->{path}", $self ); } my @exts = @{$self->{extensions}}; unless ( @exts ) { @exts = $self->{admin}->load_all_extensions; } my %seen; foreach my $obj ( @exts ) { while (my ($method, $glob) = each %{ref($obj) . '::'}) { next unless $obj->can($method); next if $method =~ /^_/; next if $method eq uc($method); $seen{$method}++; } } my $who = $self->_caller; foreach my $name ( sort keys %seen ) { local $^W; *{"${who}::$name"} = sub { ${"${who}::AUTOLOAD"} = "${who}::$name"; goto &{"${who}::AUTOLOAD"}; }; } } sub new { my ($class, %args) = @_; delete $INC{'FindBin.pm'}; { # to suppress the redefine warning local $SIG{__WARN__} = sub {}; require FindBin; } # ignore the prefix on extension modules built from top level. my $base_path = Cwd::abs_path($FindBin::Bin); unless ( Cwd::abs_path(Cwd::getcwd()) eq $base_path ) { delete $args{prefix}; } return $args{_self} if $args{_self}; $base_path = VMS::Filespec::unixify($base_path) if $^O eq 'VMS'; $args{dispatch} ||= 'Admin'; $args{prefix} ||= 'inc'; $args{author} ||= ($^O eq 'VMS' ? '_author' : '.author'); $args{bundle} ||= 'inc/BUNDLES'; $args{base} ||= $base_path; $class =~ s/^\Q$args{prefix}\E:://; $args{name} ||= $class; $args{version} ||= $class->VERSION; unless ( $args{path} ) { $args{path} = $args{name}; $args{path} =~ s!::!/!g; } $args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm"; $args{wrote} = 0; bless( \%args, $class ); } sub call { my ($self, $method) = @_; my $obj = $self->load($method) or return; splice(@_, 0, 2, $obj); goto &{$obj->can($method)}; } sub load { my ($self, $method) = @_; $self->load_extensions( "$self->{prefix}/$self->{path}", $self ) unless $self->{extensions}; foreach my $obj (@{$self->{extensions}}) { return $obj if $obj->can($method); } my $admin = $self->{admin} or die <<"END_DIE"; The '$method' method does not exist in the '$self->{prefix}' path! Please remove the '$self->{prefix}' directory and run $0 again to load it. END_DIE my $obj = $admin->load($method, 1); push @{$self->{extensions}}, $obj; $obj; } sub load_extensions { my ($self, $path, $top) = @_; my $should_reload = 0; unless ( grep { ! ref $_ and lc $_ eq lc $self->{prefix} } @INC ) { unshift @INC, $self->{prefix}; $should_reload = 1; } foreach my $rv ( $self->find_extensions($path) ) { my ($file, $pkg) = @{$rv}; next if $self->{pathnames}{$pkg}; local $@; my $new = eval { local $^W; require $file; $pkg->can('new') }; unless ( $new ) { warn $@ if $@; next; } $self->{pathnames}{$pkg} = $should_reload ? delete $INC{$file} : $INC{$file}; push @{$self->{extensions}}, &{$new}($pkg, _top => $top ); } $self->{extensions} ||= []; } sub find_extensions { my ($self, $path) = @_; my @found; File::Find::find( {no_chdir => 1, wanted => sub { my $file = $File::Find::name; return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is; my $subpath = $1; return if lc($subpath) eq lc($self->{dispatch}); $file = "$self->{path}/$subpath.pm"; my $pkg = "$self->{name}::$subpath"; $pkg =~ s!/!::!g; # If we have a mixed-case package name, assume case has been preserved # correctly. Otherwise, root through the file to locate the case-preserved # version of the package name. if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) { my $content = Module::Install::_read($File::Find::name); my $in_pod = 0; foreach ( split /\n/, $content ) { $in_pod = 1 if /^=\w/; $in_pod = 0 if /^=cut/; next if ($in_pod || /^=cut/); # skip pod text next if /^\s*#/; # and comments if ( m/^\s*package\s+($pkg)\s*;/i ) { $pkg = $1; last; } } } push @found, [ $file, $pkg ]; }}, $path ) if -d $path; @found; } ##################################################################### # Common Utility Functions sub _caller { my $depth = 0; my $call = caller($depth); while ( $call eq __PACKAGE__ ) { $depth++; $call = caller($depth); } return $call; } sub _read { local *FH; open( FH, '<', $_[0] ) or die "open($_[0]): $!"; binmode FH; my $string = do { local $/; }; close FH or die "close($_[0]): $!"; return $string; } sub _readperl { my $string = Module::Install::_read($_[0]); $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; $string =~ s/(\n)\n*__(?:DATA|END)__\b.*\z/$1/s; $string =~ s/\n\n=\w+.+?\n\n=cut\b.+?\n+/\n\n/sg; return $string; } sub _readpod { my $string = Module::Install::_read($_[0]); $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; return $string if $_[0] =~ /\.pod\z/; $string =~ s/(^|\n=cut\b.+?\n+)[^=\s].+?\n(\n=\w+|\z)/$1$2/sg; $string =~ s/\n*=pod\b[^\n]*\n+/\n\n/sg; $string =~ s/\n*=cut\b[^\n]*\n+/\n\n/sg; $string =~ s/^\n+//s; return $string; } sub _write { local *FH; open( FH, '>', $_[0] ) or die "open($_[0]): $!"; binmode FH; foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!"; } close FH or die "close($_[0]): $!"; } # _version is for processing module versions (eg, 1.03_05) not # Perl versions (eg, 5.8.1). sub _version { my $s = shift || 0; my $d =()= $s =~ /(\.)/g; if ( $d >= 2 ) { # Normalise multipart versions $s =~ s/(\.)(\d{1,3})/sprintf("$1%03d",$2)/eg; } $s =~ s/^(\d+)\.?//; my $l = $1 || 0; my @v = map { $_ . '0' x (3 - length $_) } $s =~ /(\d{1,3})\D?/g; $l = $l . '.' . join '', @v if @v; return $l + 0; } sub _cmp { _version($_[1]) <=> _version($_[2]); } # Cloned from Params::Util::_CLASS sub _CLASS { ( defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s ) ? $_[0] : undef; } 1; # Copyright 2008 - 2012 Adam Kennedy. AtteanX-Store-DBI-0.003/inc/Module/Install/Fetch.pm000644 000765 000024 00000004627 14764061647 021660 0ustar00gregstaff000000 000000 #line 1 package Module::Install::Fetch; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.21'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub get_file { my ($self, %args) = @_; my ($scheme, $host, $path, $file) = $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; if ( $scheme eq 'http' and ! eval { require LWP::Simple; 1 } ) { $args{url} = $args{ftp_url} or (warn("LWP support unavailable!\n"), return); ($scheme, $host, $path, $file) = $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; } $|++; print "Fetching '$file' from $host... "; unless (eval { require Socket; Socket::inet_aton($host) }) { warn "'$host' resolve failed!\n"; return; } return unless $scheme eq 'ftp' or $scheme eq 'http'; require Cwd; my $dir = Cwd::getcwd(); chdir $args{local_dir} or return if exists $args{local_dir}; if (eval { require LWP::Simple; 1 }) { LWP::Simple::mirror($args{url}, $file); } elsif (eval { require Net::FTP; 1 }) { eval { # use Net::FTP to get past firewall my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600); $ftp->login("anonymous", 'anonymous@example.com'); $ftp->cwd($path); $ftp->binary; $ftp->get($file) or (warn("$!\n"), return); $ftp->quit; } } elsif (my $ftp = $self->can_run('ftp')) { eval { # no Net::FTP, fallback to ftp.exe require FileHandle; my $fh = FileHandle->new; local $SIG{CHLD} = 'IGNORE'; unless ($fh->open("|$ftp -n")) { warn "Couldn't open ftp: $!\n"; chdir $dir; return; } my @dialog = split(/\n/, <<"END_FTP"); open $host user anonymous anonymous\@example.com cd $path binary get $file $file quit END_FTP foreach (@dialog) { $fh->print("$_\n") } $fh->close; } } else { warn "No working 'ftp' program available!\n"; chdir $dir; return; } unless (-f $file) { warn "Fetching failed: $@\n"; chdir $dir; return; } return if exists $args{size} and -s $file != $args{size}; system($args{run}) if exists $args{run}; unlink($file) if $args{remove}; print(((!exists $args{check_for} or -e $args{check_for}) ? "done!" : "failed! ($!)"), "\n"); chdir $dir; return !$?; } 1; AtteanX-Store-DBI-0.003/inc/Module/Install/Metadata.pm000644 000765 000024 00000043437 14764061647 022351 0ustar00gregstaff000000 000000 #line 1 package Module::Install::Metadata; use strict 'vars'; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.21'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } my @boolean_keys = qw{ sign }; my @scalar_keys = qw{ name module_name abstract version distribution_type tests installdirs }; my @tuple_keys = qw{ configure_requires build_requires requires recommends bundles resources }; my @resource_keys = qw{ homepage bugtracker repository }; my @array_keys = qw{ keywords author }; *authors = \&author; sub Meta { shift } sub Meta_BooleanKeys { @boolean_keys } sub Meta_ScalarKeys { @scalar_keys } sub Meta_TupleKeys { @tuple_keys } sub Meta_ResourceKeys { @resource_keys } sub Meta_ArrayKeys { @array_keys } foreach my $key ( @boolean_keys ) { *$key = sub { my $self = shift; if ( defined wantarray and not @_ ) { return $self->{values}->{$key}; } $self->{values}->{$key} = ( @_ ? $_[0] : 1 ); return $self; }; } foreach my $key ( @scalar_keys ) { *$key = sub { my $self = shift; return $self->{values}->{$key} if defined wantarray and !@_; $self->{values}->{$key} = shift; return $self; }; } foreach my $key ( @array_keys ) { *$key = sub { my $self = shift; return $self->{values}->{$key} if defined wantarray and !@_; $self->{values}->{$key} ||= []; push @{$self->{values}->{$key}}, @_; return $self; }; } foreach my $key ( @resource_keys ) { *$key = sub { my $self = shift; unless ( @_ ) { return () unless $self->{values}->{resources}; return map { $_->[1] } grep { $_->[0] eq $key } @{ $self->{values}->{resources} }; } return $self->{values}->{resources}->{$key} unless @_; my $uri = shift or die( "Did not provide a value to $key()" ); $self->resources( $key => $uri ); return 1; }; } foreach my $key ( grep { $_ ne "resources" } @tuple_keys) { *$key = sub { my $self = shift; return $self->{values}->{$key} unless @_; my @added; while ( @_ ) { my $module = shift or last; my $version = shift || 0; push @added, [ $module, $version ]; } push @{ $self->{values}->{$key} }, @added; return map {@$_} @added; }; } # Resource handling my %lc_resource = map { $_ => 1 } qw{ homepage license bugtracker repository }; sub resources { my $self = shift; while ( @_ ) { my $name = shift or last; my $value = shift or next; if ( $name eq lc $name and ! $lc_resource{$name} ) { die("Unsupported reserved lowercase resource '$name'"); } $self->{values}->{resources} ||= []; push @{ $self->{values}->{resources} }, [ $name, $value ]; } $self->{values}->{resources}; } # Aliases for build_requires that will have alternative # meanings in some future version of META.yml. sub test_requires { shift->build_requires(@_) } sub install_requires { shift->build_requires(@_) } # Aliases for installdirs options sub install_as_core { $_[0]->installdirs('perl') } sub install_as_cpan { $_[0]->installdirs('site') } sub install_as_site { $_[0]->installdirs('site') } sub install_as_vendor { $_[0]->installdirs('vendor') } sub dynamic_config { my $self = shift; my $value = @_ ? shift : 1; if ( $self->{values}->{dynamic_config} ) { # Once dynamic we never change to static, for safety return 0; } $self->{values}->{dynamic_config} = $value ? 1 : 0; return 1; } # Convenience command sub static_config { shift->dynamic_config(0); } sub perl_version { my $self = shift; return $self->{values}->{perl_version} unless @_; my $version = shift or die( "Did not provide a value to perl_version()" ); # Normalize the version $version = $self->_perl_version($version); # We don't support the really old versions unless ( $version >= 5.005 ) { die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n"; } $self->{values}->{perl_version} = $version; } sub all_from { my ( $self, $file ) = @_; unless ( defined($file) ) { my $name = $self->name or die( "all_from called with no args without setting name() first" ); $file = join('/', 'lib', split(/-/, $name)) . '.pm'; $file =~ s{.*/}{} unless -e $file; unless ( -e $file ) { die("all_from cannot find $file from $name"); } } unless ( -f $file ) { die("The path '$file' does not exist, or is not a file"); } $self->{values}{all_from} = $file; # Some methods pull from POD instead of code. # If there is a matching .pod, use that instead my $pod = $file; $pod =~ s/\.pm$/.pod/i; $pod = $file unless -e $pod; # Pull the different values $self->name_from($file) unless $self->name; $self->version_from($file) unless $self->version; $self->perl_version_from($file) unless $self->perl_version; $self->author_from($pod) unless @{$self->author || []}; $self->license_from($pod) unless $self->license; $self->abstract_from($pod) unless $self->abstract; return 1; } sub provides { my $self = shift; my $provides = ( $self->{values}->{provides} ||= {} ); %$provides = (%$provides, @_) if @_; return $provides; } sub auto_provides { my $self = shift; return $self unless $self->is_admin; unless (-e 'MANIFEST') { warn "Cannot deduce auto_provides without a MANIFEST, skipping\n"; return $self; } # Avoid spurious warnings as we are not checking manifest here. local $SIG{__WARN__} = sub {1}; require ExtUtils::Manifest; local *ExtUtils::Manifest::manicheck = sub { return }; require Module::Build; my $build = Module::Build->new( dist_name => $self->name, dist_version => $self->version, license => $self->license, ); $self->provides( %{ $build->find_dist_packages || {} } ); } sub feature { my $self = shift; my $name = shift; my $features = ( $self->{values}->{features} ||= [] ); my $mods; if ( @_ == 1 and ref( $_[0] ) ) { # The user used ->feature like ->features by passing in the second # argument as a reference. Accomodate for that. $mods = $_[0]; } else { $mods = \@_; } my $count = 0; push @$features, ( $name => [ map { ref($_) ? ( ref($_) eq 'HASH' ) ? %$_ : @$_ : $_ } @$mods ] ); return @$features; } sub features { my $self = shift; while ( my ( $name, $mods ) = splice( @_, 0, 2 ) ) { $self->feature( $name, @$mods ); } return $self->{values}->{features} ? @{ $self->{values}->{features} } : (); } sub no_index { my $self = shift; my $type = shift; push @{ $self->{values}->{no_index}->{$type} }, @_ if $type; return $self->{values}->{no_index}; } sub read { my $self = shift; $self->include_deps( 'YAML::Tiny', 0 ); require YAML::Tiny; my $data = YAML::Tiny::LoadFile('META.yml'); # Call methods explicitly in case user has already set some values. while ( my ( $key, $value ) = each %$data ) { next unless $self->can($key); if ( ref $value eq 'HASH' ) { while ( my ( $module, $version ) = each %$value ) { $self->can($key)->($self, $module => $version ); } } else { $self->can($key)->($self, $value); } } return $self; } sub write { my $self = shift; return $self unless $self->is_admin; $self->admin->write_meta; return $self; } sub version_from { require ExtUtils::MM_Unix; my ( $self, $file ) = @_; $self->version( ExtUtils::MM_Unix->parse_version($file) ); # for version integrity check $self->makemaker_args( VERSION_FROM => $file ); } sub abstract_from { require ExtUtils::MM_Unix; my ( $self, $file ) = @_; $self->abstract( bless( { DISTNAME => $self->name }, 'ExtUtils::MM_Unix' )->parse_abstract($file) ); } # Add both distribution and module name sub name_from { my ($self, $file) = @_; if ( Module::Install::_read($file) =~ m/ ^ \s* package \s* ([\w:]+) [\s|;]* /ixms ) { my ($name, $module_name) = ($1, $1); $name =~ s{::}{-}g; $self->name($name); unless ( $self->module_name ) { $self->module_name($module_name); } } else { die("Cannot determine name from $file\n"); } } sub _extract_perl_version { if ( $_[0] =~ m/ ^\s* (?:use|require) \s* v? ([\d_\.]+) \s* ; /ixms ) { my $perl_version = $1; $perl_version =~ s{_}{}g; return $perl_version; } else { return; } } sub perl_version_from { my $self = shift; my $perl_version=_extract_perl_version(Module::Install::_read($_[0])); if ($perl_version) { $self->perl_version($perl_version); } else { warn "Cannot determine perl version info from $_[0]\n"; return; } } sub author_from { my $self = shift; my $content = Module::Install::_read($_[0]); if ($content =~ m/ =head \d \s+ (?:authors?)\b \s* ([^\n]*) | =head \d \s+ (?:licen[cs]e|licensing|copyright|legal)\b \s* .*? copyright .*? \d\d\d[\d.]+ \s* (?:\bby\b)? \s* ([^\n]*) /ixms) { my $author = $1 || $2; # XXX: ugly but should work anyway... if (eval "require Pod::Escapes; 1") { # Pod::Escapes has a mapping table. # It's in core of perl >= 5.9.3, and should be installed # as one of the Pod::Simple's prereqs, which is a prereq # of Pod::Text 3.x (see also below). $author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } { defined $2 ? chr($2) : defined $Pod::Escapes::Name2character_number{$1} ? chr($Pod::Escapes::Name2character_number{$1}) : do { warn "Unknown escape: E<$1>"; "E<$1>"; }; }gex; } elsif (eval "require Pod::Text; 1" && $Pod::Text::VERSION < 3) { # Pod::Text < 3.0 has yet another mapping table, # though the table name of 2.x and 1.x are different. # (1.x is in core of Perl < 5.6, 2.x is in core of # Perl < 5.9.3) my $mapping = ($Pod::Text::VERSION < 2) ? \%Pod::Text::HTML_Escapes : \%Pod::Text::ESCAPES; $author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } { defined $2 ? chr($2) : defined $mapping->{$1} ? $mapping->{$1} : do { warn "Unknown escape: E<$1>"; "E<$1>"; }; }gex; } else { $author =~ s{E}{<}g; $author =~ s{E}{>}g; } $self->author($author); } else { warn "Cannot determine author info from $_[0]\n"; } } #Stolen from M::B my %license_urls = ( perl => 'http://dev.perl.org/licenses/', apache => 'http://apache.org/licenses/LICENSE-2.0', artistic => 'http://opensource.org/licenses/artistic-license.php', lgpl => 'http://opensource.org/licenses/lgpl-license.php', bsd => 'http://opensource.org/licenses/bsd-license.php', gpl => 'http://opensource.org/licenses/gpl-license.php', gpl2 => 'http://opensource.org/licenses/gpl-2.0.php', gpl3 => 'http://opensource.org/licenses/gpl-3.0.html', mit => 'http://opensource.org/licenses/mit-license.php', mozilla => 'http://opensource.org/licenses/mozilla1.1.php', open_source => undef, unrestricted => undef, restrictive => undef, unknown => undef, # these are not actually allowed in meta-spec v1.4 but are left here for compatibility: apache_1_1 => 'http://apache.org/licenses/LICENSE-1.1', artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php', lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php', lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html', ); sub license { my $self = shift; return $self->{values}->{license} unless @_; my $license = shift or die( 'Did not provide a value to license()' ); $license = __extract_license($license) || lc $license; $self->{values}->{license} = $license; # Automatically fill in license URLs if ( $license_urls{$license} ) { $self->resources( license => $license_urls{$license} ); } return 1; } sub _extract_license { my $pod = shift; my $matched; return __extract_license( ($matched) = $pod =~ m/ (=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?) (=head \d.*|=cut.*|)\z /xms ) || __extract_license( ($matched) = $pod =~ m/ (=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?) (=head \d.*|=cut.*|)\z /xms ); } sub __extract_license { my $license_text = shift or return; my @phrases = ( '(?:under )?the same (?:terms|license) as (?:perl|the perl (?:\d )?programming language)' => 'perl', 1, '(?:under )?the terms of (?:perl|the perl programming language) itself' => 'perl', 1, 'Artistic and GPL' => 'perl', 1, 'GNU general public license' => 'gpl', 1, 'GNU public license' => 'gpl', 1, 'GNU lesser general public license' => 'lgpl', 1, 'GNU lesser public license' => 'lgpl', 1, 'GNU library general public license' => 'lgpl', 1, 'GNU library public license' => 'lgpl', 1, 'GNU Free Documentation license' => 'unrestricted', 1, 'GNU Affero General Public License' => 'open_source', 1, '(?:Free)?BSD license' => 'bsd', 1, 'Artistic license 2\.0' => 'artistic_2', 1, 'Artistic license' => 'artistic', 1, 'Apache (?:Software )?license' => 'apache', 1, 'GPL' => 'gpl', 1, 'LGPL' => 'lgpl', 1, 'BSD' => 'bsd', 1, 'Artistic' => 'artistic', 1, 'MIT' => 'mit', 1, 'Mozilla Public License' => 'mozilla', 1, 'Q Public License' => 'open_source', 1, 'OpenSSL License' => 'unrestricted', 1, 'SSLeay License' => 'unrestricted', 1, 'zlib License' => 'open_source', 1, 'proprietary' => 'proprietary', 0, ); while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) { $pattern =~ s#\s+#\\s+#gs; if ( $license_text =~ /\b$pattern\b/i ) { return $license; } } return ''; } sub license_from { my $self = shift; if (my $license=_extract_license(Module::Install::_read($_[0]))) { $self->license($license); } else { warn "Cannot determine license info from $_[0]\n"; return 'unknown'; } } sub _extract_bugtracker { my @links = $_[0] =~ m#L<( https?\Q://rt.cpan.org/\E[^>]+| https?\Q://github.com/\E[\w_]+/[\w_]+/issues| https?\Q://code.google.com/p/\E[\w_\-]+/issues/list )>#gx; my %links; @links{@links}=(); @links=keys %links; return @links; } sub bugtracker_from { my $self = shift; my $content = Module::Install::_read($_[0]); my @links = _extract_bugtracker($content); unless ( @links ) { warn "Cannot determine bugtracker info from $_[0]\n"; return 0; } if ( @links > 1 ) { warn "Found more than one bugtracker link in $_[0]\n"; return 0; } # Set the bugtracker bugtracker( $links[0] ); return 1; } sub requires_from { my $self = shift; my $content = Module::Install::_readperl($_[0]); my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+(v?[\d\.]+)/mg; while ( @requires ) { my $module = shift @requires; my $version = shift @requires; $self->requires( $module => $version ); } } sub test_requires_from { my $self = shift; my $content = Module::Install::_readperl($_[0]); my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg; while ( @requires ) { my $module = shift @requires; my $version = shift @requires; $self->test_requires( $module => $version ); } } # Convert triple-part versions (eg, 5.6.1 or 5.8.9) to # numbers (eg, 5.006001 or 5.008009). # Also, convert double-part versions (eg, 5.8) sub _perl_version { my $v = $_[-1]; $v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e; $v =~ s/^([1-9])\.([1-9]\d?\d?)\.(0|[1-9]\d?\d?)$/sprintf("%d.%03d%03d",$1,$2,$3 || 0)/e; $v =~ s/(\.\d\d\d)000$/$1/; $v =~ s/_.+$//; if ( ref($v) ) { # Numify $v = $v + 0; } return $v; } sub add_metadata { my $self = shift; my %hash = @_; for my $key (keys %hash) { warn "add_metadata: $key is not prefixed with 'x_'.\n" . "Use appopriate function to add non-private metadata.\n" unless $key =~ /^x_/; $self->{values}->{$key} = $hash{$key}; } } ###################################################################### # MYMETA Support sub WriteMyMeta { die "WriteMyMeta has been deprecated"; } sub write_mymeta_yaml { my $self = shift; # We need YAML::Tiny to write the MYMETA.yml file unless ( eval { require YAML::Tiny; 1; } ) { return 1; } # Generate the data my $meta = $self->_write_mymeta_data or return 1; # Save as the MYMETA.yml file print "Writing MYMETA.yml\n"; YAML::Tiny::DumpFile('MYMETA.yml', $meta); } sub write_mymeta_json { my $self = shift; # We need JSON to write the MYMETA.json file unless ( eval { require JSON; 1; } ) { return 1; } # Generate the data my $meta = $self->_write_mymeta_data or return 1; # Save as the MYMETA.yml file print "Writing MYMETA.json\n"; Module::Install::_write( 'MYMETA.json', JSON->new->pretty(1)->canonical->encode($meta), ); } sub _write_mymeta_data { my $self = shift; # If there's no existing META.yml there is nothing we can do return undef unless -f 'META.yml'; # We need Parse::CPAN::Meta to load the file unless ( eval { require Parse::CPAN::Meta; 1; } ) { return undef; } # Merge the perl version into the dependencies my $val = $self->Meta->{values}; my $perl = delete $val->{perl_version}; if ( $perl ) { $val->{requires} ||= []; my $requires = $val->{requires}; # Canonize to three-dot version after Perl 5.6 if ( $perl >= 5.006 ) { $perl =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2||0), int($3||0))}e } unshift @$requires, [ perl => $perl ]; } # Load the advisory META.yml file my @yaml = Parse::CPAN::Meta::LoadFile('META.yml'); my $meta = $yaml[0]; # Overwrite the non-configure dependency hashes delete $meta->{requires}; delete $meta->{build_requires}; delete $meta->{recommends}; if ( exists $val->{requires} ) { $meta->{requires} = { map { @$_ } @{ $val->{requires} } }; } if ( exists $val->{build_requires} ) { $meta->{build_requires} = { map { @$_ } @{ $val->{build_requires} } }; } return $meta; } 1; AtteanX-Store-DBI-0.003/inc/Module/Install/AuthorTests.pm000644 000765 000024 00000002215 14764061647 023103 0ustar00gregstaff000000 000000 #line 1 package Module::Install::AuthorTests; use 5.005; use strict; use Module::Install::Base; use Carp (); #line 16 use vars qw{$VERSION $ISCORE @ISA}; BEGIN { $VERSION = '0.002'; $ISCORE = 1; @ISA = qw{Module::Install::Base}; } #line 42 sub author_tests { my ($self, @dirs) = @_; _add_author_tests($self, \@dirs, 0); } #line 56 sub recursive_author_tests { my ($self, @dirs) = @_; _add_author_tests($self, \@dirs, 1); } sub _wanted { my $href = shift; sub { /\.t$/ and -f $_ and $href->{$File::Find::dir} = 1 } } sub _add_author_tests { my ($self, $dirs, $recurse) = @_; return unless $Module::Install::AUTHOR; my @tests = $self->tests ? (split / /, $self->tests) : 't/*.t'; # XXX: pick a default, later -- rjbs, 2008-02-24 my @dirs = @$dirs ? @$dirs : Carp::confess "no dirs given to author_tests"; @dirs = grep { -d } @dirs; if ($recurse) { require File::Find; my %test_dir; File::Find::find(_wanted(\%test_dir), @dirs); $self->tests( join ' ', @tests, map { "$_/*.t" } sort keys %test_dir ); } else { $self->tests( join ' ', @tests, map { "$_/*.t" } sort @dirs ); } } #line 107 1; AtteanX-Store-DBI-0.003/inc/Module/Install/Win32.pm000644 000765 000024 00000003403 14764061647 021520 0ustar00gregstaff000000 000000 #line 1 package Module::Install::Win32; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.21'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } # determine if the user needs nmake, and download it if needed sub check_nmake { my $self = shift; $self->load('can_run'); $self->load('get_file'); require Config; return unless ( $^O eq 'MSWin32' and $Config::Config{make} and $Config::Config{make} =~ /^nmake\b/i and ! $self->can_run('nmake') ); print "The required 'nmake' executable not found, fetching it...\n"; require File::Basename; my $rv = $self->get_file( url => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe', ftp_url => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe', local_dir => File::Basename::dirname($^X), size => 51928, run => 'Nmake15.exe /o > nul', check_for => 'Nmake.exe', remove => 1, ); die <<'END_MESSAGE' unless $rv; ------------------------------------------------------------------------------- Since you are using Microsoft Windows, you will need the 'nmake' utility before installation. It's available at: http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe or ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe Please download the file manually, save it to a directory in %PATH% (e.g. C:\WINDOWS\COMMAND\), then launch the MS-DOS command line shell, "cd" to that directory, and run "Nmake15.exe" from there; that will create the 'nmake.exe' file needed by this module. You may then resume the installation process described in README. ------------------------------------------------------------------------------- END_MESSAGE } 1; AtteanX-Store-DBI-0.003/inc/Module/Install/DOAPChangeSets.pm000644 000765 000024 00000000616 14764061647 023311 0ustar00gregstaff000000 000000 #line 1 package Module::Install::DOAPChangeSets; use 5.008; use parent qw(Module::Install::Base); use strict; our $VERSION = '0.206'; our $AUTHOR_ONLY = 1; sub write_doap_changes { my $self = shift; $self->admin->write_doap_changes(@_) if $self->is_admin; } sub write_doap_changes_xml { my $self = shift; $self->admin->write_doap_changes_xml(@_) if $self->is_admin; } 1; __END__ #line 84 AtteanX-Store-DBI-0.003/inc/Module/Install/WriteAll.pm000644 000765 000024 00000002376 14764061647 022351 0ustar00gregstaff000000 000000 #line 1 package Module::Install::WriteAll; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.21'; @ISA = qw{Module::Install::Base}; $ISCORE = 1; } sub WriteAll { my $self = shift; my %args = ( meta => 1, sign => 0, inline => 0, check_nmake => 1, @_, ); $self->sign(1) if $args{sign}; $self->admin->WriteAll(%args) if $self->is_admin; $self->check_nmake if $args{check_nmake}; unless ( $self->makemaker_args->{PL_FILES} ) { # XXX: This still may be a bit over-defensive... unless ($self->makemaker(6.25)) { $self->makemaker_args( PL_FILES => {} ) if -f 'Build.PL'; } } # Until ExtUtils::MakeMaker support MYMETA.yml, make sure # we clean it up properly ourself. $self->realclean_files('MYMETA.yml'); if ( $args{inline} ) { $self->Inline->write; } else { $self->Makefile->write; } # The Makefile write process adds a couple of dependencies, # so write the META.yml files after the Makefile. if ( $args{meta} ) { $self->Meta->write; } # Experimental support for MYMETA if ( $ENV{X_MYMETA} ) { if ( $ENV{X_MYMETA} eq 'JSON' ) { $self->Meta->write_mymeta_json; } else { $self->Meta->write_mymeta_yaml; } } return 1; } 1; AtteanX-Store-DBI-0.003/inc/Module/Install/Can.pm000644 000765 000024 00000006405 14764061647 021324 0ustar00gregstaff000000 000000 #line 1 package Module::Install::Can; use strict; use Config (); use ExtUtils::MakeMaker (); use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.21'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } # check if we can load some module ### Upgrade this to not have to load the module if possible sub can_use { my ($self, $mod, $ver) = @_; $mod =~ s{::|\\}{/}g; $mod .= '.pm' unless $mod =~ /\.pm$/i; my $pkg = $mod; $pkg =~ s{/}{::}g; $pkg =~ s{\.pm$}{}i; local $@; eval { require $mod; $pkg->VERSION($ver || 0); 1 }; } # Check if we can run some command sub can_run { my ($self, $cmd) = @_; my $_cmd = $cmd; return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd)); for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { next if $dir eq ''; require File::Spec; my $abs = File::Spec->catfile($dir, $cmd); return $abs if (-x $abs or $abs = MM->maybe_command($abs)); } return; } # Can our C compiler environment build XS files sub can_xs { my $self = shift; # Ensure we have the CBuilder module $self->configure_requires( 'ExtUtils::CBuilder' => 0.27 ); # Do we have the configure_requires checker? local $@; eval "require ExtUtils::CBuilder;"; if ( $@ ) { # They don't obey configure_requires, so it is # someone old and delicate. Try to avoid hurting # them by falling back to an older simpler test. return $self->can_cc(); } # Do we have a working C compiler my $builder = ExtUtils::CBuilder->new( quiet => 1, ); unless ( $builder->have_compiler ) { # No working C compiler return 0; } # Write a C file representative of what XS becomes require File::Temp; my ( $FH, $tmpfile ) = File::Temp::tempfile( "compilexs-XXXXX", SUFFIX => '.c', ); binmode $FH; print $FH <<'END_C'; #include "EXTERN.h" #include "perl.h" #include "XSUB.h" int main(int argc, char **argv) { return 0; } int boot_sanexs() { return 1; } END_C close $FH; # Can the C compiler access the same headers XS does my @libs = (); my $object = undef; eval { local $^W = 0; $object = $builder->compile( source => $tmpfile, ); @libs = $builder->link( objects => $object, module_name => 'sanexs', ); }; my $result = $@ ? 0 : 1; # Clean up all the build files foreach ( $tmpfile, $object, @libs ) { next unless defined $_; 1 while unlink; } return $result; } # Can we locate a (the) C compiler sub can_cc { my $self = shift; if ($^O eq 'VMS') { require ExtUtils::CBuilder; my $builder = ExtUtils::CBuilder->new( quiet => 1, ); return $builder->have_compiler; } my @chunks = split(/ /, $Config::Config{cc}) or return; # $Config{cc} may contain args; try to find out the program part while (@chunks) { return $self->can_run("@chunks") || (pop(@chunks), next); } return; } # Fix Cygwin bug on maybe_command(); if ( $^O eq 'cygwin' ) { require ExtUtils::MM_Cygwin; require ExtUtils::MM_Win32; if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) { *ExtUtils::MM_Cygwin::maybe_command = sub { my ($self, $file) = @_; if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) { ExtUtils::MM_Win32->maybe_command($file); } else { ExtUtils::MM_Unix->maybe_command($file); } } } } 1; __END__ #line 245 AtteanX-Store-DBI-0.003/inc/Module/Install/Makefile.pm000644 000765 000024 00000027437 14764061647 022350 0ustar00gregstaff000000 000000 #line 1 package Module::Install::Makefile; use strict 'vars'; use ExtUtils::MakeMaker (); use Module::Install::Base (); use Fcntl qw/:flock :seek/; use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.21'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub Makefile { $_[0] } my %seen = (); sub prompt { shift; # Infinite loop protection my @c = caller(); if ( ++$seen{"$c[1]|$c[2]|$_[0]"} > 3 ) { die "Caught an potential prompt infinite loop ($c[1]|$c[2]|$_[0])"; } # In automated testing or non-interactive session, always use defaults if ( ($ENV{AUTOMATED_TESTING} or -! -t STDIN) and ! $ENV{PERL_MM_USE_DEFAULT} ) { local $ENV{PERL_MM_USE_DEFAULT} = 1; goto &ExtUtils::MakeMaker::prompt; } else { goto &ExtUtils::MakeMaker::prompt; } } # Store a cleaned up version of the MakeMaker version, # since we need to behave differently in a variety of # ways based on the MM version. my $makemaker = eval $ExtUtils::MakeMaker::VERSION; # If we are passed a param, do a "newer than" comparison. # Otherwise, just return the MakeMaker version. sub makemaker { ( @_ < 2 or $makemaker >= eval($_[1]) ) ? $makemaker : 0 } # Ripped from ExtUtils::MakeMaker 6.56, and slightly modified # as we only need to know here whether the attribute is an array # or a hash or something else (which may or may not be appendable). my %makemaker_argtype = ( C => 'ARRAY', CONFIG => 'ARRAY', # CONFIGURE => 'CODE', # ignore DIR => 'ARRAY', DL_FUNCS => 'HASH', DL_VARS => 'ARRAY', EXCLUDE_EXT => 'ARRAY', EXE_FILES => 'ARRAY', FUNCLIST => 'ARRAY', H => 'ARRAY', IMPORTS => 'HASH', INCLUDE_EXT => 'ARRAY', LIBS => 'ARRAY', # ignore '' MAN1PODS => 'HASH', MAN3PODS => 'HASH', META_ADD => 'HASH', META_MERGE => 'HASH', PL_FILES => 'HASH', PM => 'HASH', PMLIBDIRS => 'ARRAY', PMLIBPARENTDIRS => 'ARRAY', PREREQ_PM => 'HASH', CONFIGURE_REQUIRES => 'HASH', SKIP => 'ARRAY', TYPEMAPS => 'ARRAY', XS => 'HASH', # VERSION => ['version',''], # ignore # _KEEP_AFTER_FLUSH => '', clean => 'HASH', depend => 'HASH', dist => 'HASH', dynamic_lib=> 'HASH', linkext => 'HASH', macro => 'HASH', postamble => 'HASH', realclean => 'HASH', test => 'HASH', tool_autosplit => 'HASH', # special cases where you can use makemaker_append CCFLAGS => 'APPENDABLE', DEFINE => 'APPENDABLE', INC => 'APPENDABLE', LDDLFLAGS => 'APPENDABLE', LDFROM => 'APPENDABLE', ); sub makemaker_args { my ($self, %new_args) = @_; my $args = ( $self->{makemaker_args} ||= {} ); foreach my $key (keys %new_args) { if ($makemaker_argtype{$key}) { if ($makemaker_argtype{$key} eq 'ARRAY') { $args->{$key} = [] unless defined $args->{$key}; unless (ref $args->{$key} eq 'ARRAY') { $args->{$key} = [$args->{$key}] } push @{$args->{$key}}, ref $new_args{$key} eq 'ARRAY' ? @{$new_args{$key}} : $new_args{$key}; } elsif ($makemaker_argtype{$key} eq 'HASH') { $args->{$key} = {} unless defined $args->{$key}; foreach my $skey (keys %{ $new_args{$key} }) { $args->{$key}{$skey} = $new_args{$key}{$skey}; } } elsif ($makemaker_argtype{$key} eq 'APPENDABLE') { $self->makemaker_append($key => $new_args{$key}); } } else { if (defined $args->{$key}) { warn qq{MakeMaker attribute "$key" is overriden; use "makemaker_append" to append values\n}; } $args->{$key} = $new_args{$key}; } } return $args; } # For mm args that take multiple space-separated args, # append an argument to the current list. sub makemaker_append { my $self = shift; my $name = shift; my $args = $self->makemaker_args; $args->{$name} = defined $args->{$name} ? join( ' ', $args->{$name}, @_ ) : join( ' ', @_ ); } sub build_subdirs { my $self = shift; my $subdirs = $self->makemaker_args->{DIR} ||= []; for my $subdir (@_) { push @$subdirs, $subdir; } } sub clean_files { my $self = shift; my $clean = $self->makemaker_args->{clean} ||= {}; %$clean = ( %$clean, FILES => join ' ', grep { length $_ } ($clean->{FILES} || (), @_), ); } sub realclean_files { my $self = shift; my $realclean = $self->makemaker_args->{realclean} ||= {}; %$realclean = ( %$realclean, FILES => join ' ', grep { length $_ } ($realclean->{FILES} || (), @_), ); } sub libs { my $self = shift; my $libs = ref $_[0] ? shift : [ shift ]; $self->makemaker_args( LIBS => $libs ); } sub inc { my $self = shift; $self->makemaker_args( INC => shift ); } sub _wanted_t { } sub tests_recursive { my $self = shift; my $dir = shift || 't'; unless ( -d $dir ) { die "tests_recursive dir '$dir' does not exist"; } my %tests = map { $_ => 1 } split / /, ($self->tests || ''); require File::Find; File::Find::find( sub { /\.t$/ and -f $_ and $tests{"$File::Find::dir/*.t"} = 1 }, $dir ); $self->tests( join ' ', sort keys %tests ); } sub write { my $self = shift; die "&Makefile->write() takes no arguments\n" if @_; # Check the current Perl version my $perl_version = $self->perl_version; if ( $perl_version ) { eval "use $perl_version; 1" or die "ERROR: perl: Version $] is installed, " . "but we need version >= $perl_version"; } # Make sure we have a new enough MakeMaker require ExtUtils::MakeMaker; if ( $perl_version and $self->_cmp($perl_version, '5.006') >= 0 ) { # This previous attempted to inherit the version of # ExtUtils::MakeMaker in use by the module author, but this # was found to be untenable as some authors build releases # using future dev versions of EU:MM that nobody else has. # Instead, #toolchain suggests we use 6.59 which is the most # stable version on CPAN at time of writing and is, to quote # ribasushi, "not terminally fucked, > and tested enough". # TODO: We will now need to maintain this over time to push # the version up as new versions are released. $self->build_requires( 'ExtUtils::MakeMaker' => 6.59 ); $self->configure_requires( 'ExtUtils::MakeMaker' => 6.59 ); } else { # Allow legacy-compatibility with 5.005 by depending on the # most recent EU:MM that supported 5.005. $self->build_requires( 'ExtUtils::MakeMaker' => 6.36 ); $self->configure_requires( 'ExtUtils::MakeMaker' => 6.36 ); } # Generate the MakeMaker params my $args = $self->makemaker_args; $args->{DISTNAME} = $self->name; $args->{NAME} = $self->module_name || $self->name; $args->{NAME} =~ s/-/::/g; $args->{VERSION} = $self->version or die <<'EOT'; ERROR: Can't determine distribution version. Please specify it explicitly via 'version' in Makefile.PL, or set a valid $VERSION in a module, and provide its file path via 'version_from' (or 'all_from' if you prefer) in Makefile.PL. EOT if ( $self->tests ) { my @tests = split ' ', $self->tests; my %seen; $args->{test} = { TESTS => (join ' ', grep {!$seen{$_}++} @tests), }; } elsif ( $Module::Install::ExtraTests::use_extratests ) { # Module::Install::ExtraTests doesn't set $self->tests and does its own tests via harness. # So, just ignore our xt tests here. } elsif ( -d 'xt' and ($Module::Install::AUTHOR or $ENV{RELEASE_TESTING}) ) { $args->{test} = { TESTS => join( ' ', map { "$_/*.t" } grep { -d $_ } qw{ t xt } ), }; } if ( $] >= 5.005 ) { $args->{ABSTRACT} = $self->abstract; $args->{AUTHOR} = join ', ', @{$self->author || []}; } if ( $self->makemaker(6.10) ) { $args->{NO_META} = 1; #$args->{NO_MYMETA} = 1; } if ( $self->makemaker(6.17) and $self->sign ) { $args->{SIGN} = 1; } unless ( $self->is_admin ) { delete $args->{SIGN}; } if ( $self->makemaker(6.31) and $self->license ) { $args->{LICENSE} = $self->license; } my $prereq = ($args->{PREREQ_PM} ||= {}); %$prereq = ( %$prereq, map { @$_ } # flatten [module => version] map { @$_ } grep $_, ($self->requires) ); # Remove any reference to perl, PREREQ_PM doesn't support it delete $args->{PREREQ_PM}->{perl}; # Merge both kinds of requires into BUILD_REQUIRES my $build_prereq = ($args->{BUILD_REQUIRES} ||= {}); %$build_prereq = ( %$build_prereq, map { @$_ } # flatten [module => version] map { @$_ } grep $_, ($self->configure_requires, $self->build_requires) ); # Remove any reference to perl, BUILD_REQUIRES doesn't support it delete $args->{BUILD_REQUIRES}->{perl}; # Delete bundled dists from prereq_pm, add it to Makefile DIR my $subdirs = ($args->{DIR} || []); if ($self->bundles) { my %processed; foreach my $bundle (@{ $self->bundles }) { my ($mod_name, $dist_dir) = @$bundle; delete $prereq->{$mod_name}; $dist_dir = File::Basename::basename($dist_dir); # dir for building this module if (not exists $processed{$dist_dir}) { if (-d $dist_dir) { # List as sub-directory to be processed by make push @$subdirs, $dist_dir; } # Else do nothing: the module is already present on the system $processed{$dist_dir} = undef; } } } unless ( $self->makemaker('6.55_03') ) { %$prereq = (%$prereq,%$build_prereq); delete $args->{BUILD_REQUIRES}; } if ( my $perl_version = $self->perl_version ) { eval "use $perl_version; 1" or die "ERROR: perl: Version $] is installed, " . "but we need version >= $perl_version"; if ( $self->makemaker(6.48) ) { $args->{MIN_PERL_VERSION} = $perl_version; } } if ($self->installdirs) { warn qq{old INSTALLDIRS (probably set by makemaker_args) is overriden by installdirs\n} if $args->{INSTALLDIRS}; $args->{INSTALLDIRS} = $self->installdirs; } my %args = map { ( $_ => $args->{$_} ) } grep {defined($args->{$_} ) } keys %$args; my $user_preop = delete $args{dist}->{PREOP}; if ( my $preop = $self->admin->preop($user_preop) ) { foreach my $key ( keys %$preop ) { $args{dist}->{$key} = $preop->{$key}; } } my $mm = ExtUtils::MakeMaker::WriteMakefile(%args); $self->fix_up_makefile($mm->{FIRST_MAKEFILE} || 'Makefile'); } sub fix_up_makefile { my $self = shift; my $makefile_name = shift; my $top_class = ref($self->_top) || ''; my $top_version = $self->_top->VERSION || ''; my $preamble = $self->preamble ? "# Preamble by $top_class $top_version\n" . $self->preamble : ''; my $postamble = "# Postamble by $top_class $top_version\n" . ($self->postamble || ''); local *MAKEFILE; open MAKEFILE, "+< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!"; eval { flock MAKEFILE, LOCK_EX }; my $makefile = do { local $/; }; $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /; $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g; $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g; $makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m; $makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m; # Module::Install will never be used to build the Core Perl # Sometimes PERL_LIB and PERL_ARCHLIB get written anyway, which breaks # PREFIX/PERL5LIB, and thus, install_share. Blank them if they exist $makefile =~ s/^PERL_LIB = .+/PERL_LIB =/m; #$makefile =~ s/^PERL_ARCHLIB = .+/PERL_ARCHLIB =/m; # Perl 5.005 mentions PERL_LIB explicitly, so we have to remove that as well. $makefile =~ s/(\"?)-I\$\(PERL_LIB\)\1//g; # XXX - This is currently unused; not sure if it breaks other MM-users # $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg; seek MAKEFILE, 0, SEEK_SET; truncate MAKEFILE, 0; print MAKEFILE "$preamble$makefile$postamble" or die $!; close MAKEFILE or die $!; 1; } sub preamble { my ($self, $text) = @_; $self->{preamble} = $text . $self->{preamble} if defined $text; $self->{preamble}; } sub postamble { my ($self, $text) = @_; $self->{postamble} ||= $self->admin->postamble; $self->{postamble} .= $text if defined $text; $self->{postamble} } 1; __END__ #line 544 AtteanX-Store-DBI-0.003/inc/Module/Install/Share.pm000644 000765 000024 00000004643 14764061647 021667 0ustar00gregstaff000000 000000 #line 1 package Module::Install::Share; use strict; use Module::Install::Base (); use File::Find (); use ExtUtils::Manifest (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.21'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub install_share { my $self = shift; my $dir = @_ ? pop : 'share'; my $type = @_ ? shift : 'dist'; unless ( defined $type and $type eq 'module' or $type eq 'dist' ) { die "Illegal or invalid share dir type '$type'"; } unless ( defined $dir and -d $dir ) { require Carp; Carp::croak("Illegal or missing directory install_share param: '$dir'"); } # Split by type my $S = ($^O eq 'MSWin32') ? "\\" : "\/"; my $root; if ( $type eq 'dist' ) { die "Too many parameters to install_share" if @_; # Set up the install $root = "\$(INST_LIB)${S}auto${S}share${S}dist${S}\$(DISTNAME)"; } else { my $module = Module::Install::_CLASS($_[0]); unless ( defined $module ) { die "Missing or invalid module name '$_[0]'"; } $module =~ s/::/-/g; $root = "\$(INST_LIB)${S}auto${S}share${S}module${S}$module"; } my $manifest = -r 'MANIFEST' ? ExtUtils::Manifest::maniread() : undef; my $skip_checker = $ExtUtils::Manifest::VERSION >= 1.54 ? ExtUtils::Manifest::maniskip() : ExtUtils::Manifest::_maniskip(); my $postamble = ''; my $perm_dir = eval($ExtUtils::MakeMaker::VERSION) >= 6.52 ? '$(PERM_DIR)' : 755; File::Find::find({ no_chdir => 1, wanted => sub { my $path = File::Spec->abs2rel($_, $dir); if (-d $_) { return if $skip_checker->($File::Find::name); $postamble .=<<"END"; \t\$(NOECHO) \$(MKPATH) "$root${S}$path" \t\$(NOECHO) \$(CHMOD) $perm_dir "$root${S}$path" END } else { return if ref $manifest && !exists $manifest->{$File::Find::name}; return if $skip_checker->($File::Find::name); $postamble .=<<"END"; \t\$(NOECHO) \$(CP) "$dir${S}$path" "$root${S}$path" END } }, }, $dir); # Set up the install $self->postamble(<<"END_MAKEFILE"); config :: $postamble END_MAKEFILE # The above appears to behave incorrectly when used with old versions # of ExtUtils::Install (known-bad on RHEL 3, with 5.8.0) # So when we need to install a share directory, make sure we add a # dependency on a moderately new version of ExtUtils::MakeMaker. $self->build_requires( 'ExtUtils::MakeMaker' => '6.11' ); # 99% of the time we don't want to index a shared dir $self->no_index( directory => $dir ); } 1; __END__ #line 154 AtteanX-Store-DBI-0.003/inc/Module/Install/Scripts.pm000644 000765 000024 00000001011 14764061647 022236 0ustar00gregstaff000000 000000 #line 1 package Module::Install::Scripts; use strict 'vars'; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.21'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub install_script { my $self = shift; my $args = $self->makemaker_args; my $exe = $args->{EXE_FILES} ||= []; foreach ( @_ ) { if ( -f $_ ) { push @$exe, $_; } elsif ( -d 'script' and -f "script/$_" ) { push @$exe, "script/$_"; } else { die("Cannot find script '$_'"); } } } 1; AtteanX-Store-DBI-0.003/inc/Module/Install/Base.pm000644 000765 000024 00000002147 14764061647 021474 0ustar00gregstaff000000 000000 #line 1 package Module::Install::Base; use strict 'vars'; use vars qw{$VERSION}; BEGIN { $VERSION = '1.21'; } # Suspend handler for "redefined" warnings BEGIN { my $w = $SIG{__WARN__}; $SIG{__WARN__} = sub { $w }; } #line 42 sub new { my $class = shift; unless ( defined &{"${class}::call"} ) { *{"${class}::call"} = sub { shift->_top->call(@_) }; } unless ( defined &{"${class}::load"} ) { *{"${class}::load"} = sub { shift->_top->load(@_) }; } bless { @_ }, $class; } #line 61 sub AUTOLOAD { local $@; my $func = eval { shift->_top->autoload } or return; goto &$func; } #line 75 sub _top { $_[0]->{_top}; } #line 90 sub admin { $_[0]->_top->{admin} or Module::Install::Base::FakeAdmin->new; } #line 106 sub is_admin { ! $_[0]->admin->isa('Module::Install::Base::FakeAdmin'); } sub DESTROY {} package Module::Install::Base::FakeAdmin; use vars qw{$VERSION}; BEGIN { $VERSION = $Module::Install::Base::VERSION; } my $fake; sub new { $fake ||= bless(\@_, $_[0]); } sub AUTOLOAD {} sub DESTROY {} # Restore warning handler BEGIN { $SIG{__WARN__} = $SIG{__WARN__}->(); } 1; #line 159