This file is indexed.

/usr/share/perl5/DBIx/DataSource.pm is in libdbix-datasource-perl 0.02-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
package DBIx::DataSource;

use strict;
use vars qw($VERSION @ISA @EXPORT_OK $errstr);
use Exporter;

@ISA = qw(Exporter);
@EXPORT_OK = qw( create_database drop_database );

$VERSION = '0.02';

=head1 NAME

DBIx::DataSource - Database-independant create and drop functions

=head1 SYNOPSIS

  use DBIx::DataSource qw( create_database drop_database );

  create_database( $data_source, $username, $password )
    or warn $DBIx::DataSource::errstr;

  drop_database( $data_source, $username, $password )
    or warn $DBIx::DataSource::errstr;

=head1 DESCRIPTION

This module implements create_database and drop_database functions for
databases.  It aims to provide a common interface to database creation and
deletion regardless of the actual database being used.

Currently supported databases are MySQL and PostgreSQL.  Assistance adding
support for other databases is welcomed and relatively simple - see
L<DBIx::DataSource::Driver>.

=head1 FUNCTIONS

=over 4

=item create_database DATA_SOURCE USERNAME PASSWORD

Create the database specified by the given DBI data source.

=cut

sub create_database {
  my( $dsn, $user, $pass ) = @_;
  my $driver = _load_driver($dsn);
  eval "DBIx::DataSource::$driver->create_database( \$dsn, \$user, \$pass )"
    or do { $errstr=$@ if $@; ''; };
}

=item drop_database DATA_SOURCE

Drop the database specified by the given DBI data source.

=cut

sub drop_database {
  my( $dsn, $user, $pass ) = @_;
  my $driver = _load_driver($dsn);
  eval "DBIx::DataSource::$driver->drop_database( \$dsn, \$user, \$pass )"
    or do { $errstr=$@ if $@; ''; };
}

sub _load_driver {
  my $datasrc = shift;
  $datasrc =~ s/^dbi:(\w*?)(?:\((.*?)\))?://i #nicked from DBI->connect
                        or '' =~ /()/; # ensure $1 etc are empty if match fails
  my $driver = $1 or die "can't parse data source: $datasrc";
  require "DBIx/DataSource/$driver.pm";
  $driver;
}

=back

=head1 AUTHOR

Ivan Kohler <ivan-dbix-datasource@420.am>

=head1 COPYRIGHT

Copyright (c) 2000 Ivan Kohler
Copyright (c) 2000 Mail Abuse Prevention System LLC
All rights reserved.
This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.

=head1 BUGS

If DBI data sources were objects, these functions would be methods.

=head1 SEE ALSO

L<DBIx::DataSource::Driver>, L<DBIx::DataSource::mysql>, L<DBIx::DataSource::Pg>,
L<DBI>

=cut

1;