This file is indexed.

/usr/share/perl5/DBI/Test/Case/basic/prepare.pm is in libdbi-test-perl 0.001-1.

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
package DBI::Test::Case::basic::prepare;

use strict;
use warnings;

use parent qw(DBI::Test::Case);

use Test::More;

sub run_test
{
    my @DB_CREDS = @{ $_[1] };
    my %SQLS = (
                 'SELECT' => 'SELECT 1+1',
                 'INSERT' => undef
               );

    {    #Basic test
        my $dbh = DBI->connect(@DB_CREDS);
        isa_ok( $dbh, 'DBI::db' );

        my $sth;
        eval { $sth = $dbh->prepare( $SQLS{SELECT} ); };
        ok( !$@, "Prepared query" );
      SKIP:
        {
            skip "Could not prepare query", 1 if !$sth;
            isa_ok( $sth, 'DBI::st' );
        }
    }

    {    #Prepare should fail

      TODO:
        {
            local $TODO = "Must have an API to make prepare fail";
            my $dbh = DBI->connect( @DB_CREDS[ 0 .. 2 ], {} );
            isa_ok( $dbh, 'DBI::db' );

            #Do something so that prepare fails

            my $sth = $dbh->prepare( $SQLS{SELECT} );
            ok( !$sth, "Prepared failed" );
            #Check that $DBI::err && $DBI::errstr is set
            #It should be set after a failed call
            ok( $DBI::err,    '$DBI::err is set' );
            ok( $DBI::errstr, '$DBI::errstr is set' );
        }
    }

    {    #Prepare should print a warning if PrintError is set

      TODO:
        {
            local $TODO = "Must have an API to make prepare fail";
            my $dbh = DBI->connect( @DB_CREDS[ 0 .. 2 ], { PrintError => 1 } );
            isa_ok( $dbh, 'DBI::db' );

            my $warnings = 0;

            #Make sure we fetch the local
            local $SIG{__WARN__} = sub {
                $warnings++;    #TODO : Must be the correct warning
            };

            #Do something so that prepare fails

            my $sth = $dbh->prepare( $SQLS{SELECT} );
            ok( !$sth, "prepare failed" );
            cmp_ok( $warnings, '>', 0, "Recorded a warning" );
        }
    }
    {                           #Prepare should die if RaiseError is set

      TODO:
        {
            local $TODO = "Must have an API to make prepare fail";
            my $dbh = DBI->connect( @DB_CREDS[ 0 .. 2 ], { RaiseError => 1 } );
            isa_ok( $dbh, 'DBI::db' );

            #Do something so that prepare fails

            my $sth;
            eval { $sth = $dbh->prepare( $SQLS{SELECT} ); };
            ok( $@,    "prepare died" );
            ok( !$sth, 'sth is undef' );
        }
    }

    done_testing();
}

1;