This file is indexed.

/usr/share/perl5/Alzabo/Runtime.pm is in libalzabo-perl 0.92-4.

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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
package Alzabo::Runtime;

use strict;

use Alzabo;

use Alzabo::Runtime::Column;
use Alzabo::Runtime::ColumnDefinition;
use Alzabo::Runtime::ForeignKey;
use Alzabo::Runtime::Index;
use Alzabo::Runtime::InsertHandle;
use Alzabo::Runtime::JoinCursor;
use Alzabo::Runtime::Row;
use Alzabo::Runtime::RowCursor;
use Alzabo::Runtime::Schema;
use Alzabo::Runtime::Table;
use Alzabo::Utils;

use vars qw($VERSION);

$VERSION = 2.0;

1;

sub import
{
    shift;

    # ignore errors and let them be handled later in the app when it
    # tries to access the schema.
    eval { Alzabo::Runtime::Schema->load_from_file( name => $_ ); } foreach @_;
}

sub sqlmaker
{
    my ($schema, $p) = @_;

    my %sqlmaker_p = ( exists $p->{quote_identifiers} ?
                       ( quote_identifiers => $p->{quote_identifiers} ) :
                       ()
                     );

    return $schema->sqlmaker(%sqlmaker_p);
}

sub process_where_clause
{
    my ($sql, $where) = @_;

    $where = [ $where ]
        unless Alzabo::Utils::is_arrayref( $where->[0] ) || $where->[0] eq '(';

    my $has_where =
        ( $sql->last_op eq 'where' || $sql->last_op eq 'condition' ) ? 1 : 0;

    _process_conditions( $sql, $has_where, $where, 'where' );
}

sub process_having_clause
{
    my ($sql, $having) = @_;

    $having = [ $having ]
        unless Alzabo::Utils::is_arrayref( $having->[0] ) || $having->[0] eq '(';

    my $has_having =
        ( $sql->last_op eq 'having' || $sql->last_op eq 'condition' ) ? 1 : 0;

    _process_conditions( $sql, $has_having, $having, 'having' );
}

sub _process_conditions
{
    my ($sql, $has_start, $conditions, $needed_op) = @_;

    my $needs_op = $sql->last_op eq 'where' || $sql->last_op eq 'having' ? 0 : 1;

    if ($has_start)
    {
        # wrap this in parens in order to protect from interactions with
        # join clauses
        $sql->and if $needs_op;

        $sql->subgroup_start;

        $needs_op = 0;
    }

    my $x = 0;
    foreach my $clause (@$conditions)
    {
        if (ref $clause)
        {
            Alzabo::Exception::Params->throw
                ( error => "Individual where clause components must be array references" )
                    unless Alzabo::Utils::is_arrayref($clause);

            Alzabo::Exception::Params->throw
                ( error => "Individual where clause components cannot be empty" )
                    unless @$clause;

            if ($needs_op)
            {
                my $op = $x || $has_start ? 'and' : $needed_op;
                $sql->$op();
            }

            $sql->condition(@$clause);
            $needs_op = 1;
        }
        elsif (lc $clause eq 'and' || lc $clause eq 'or')
        {
            $sql->$clause();
            $needs_op = 0;
            next;
        }
        elsif ($clause eq '(')
        {
            if ($needs_op)
            {
                my $op = $x || $has_start ? 'and' : $needed_op;
                $sql->$op();
            }
            $sql->subgroup_start;
            $needs_op = 0;
        }
        elsif ($clause eq ')')
        {
            $sql->subgroup_end;
            $needs_op = 1;
        }
        else
        {
            Alzabo::Exception::Params->throw( error => "Invalid where clause specification: $clause" );
        }
        $x++;
    }

    $sql->subgroup_end if $has_start;
}

sub process_order_by_clause
{
    _process_by_clause(@_, 'order');
}

sub process_group_by_clause
{
    _process_by_clause(@_, 'group');
}

sub _process_by_clause
{
    my ($sql, $by, $type) = @_;

    my @items;
    if ( Alzabo::Utils::safe_isa( $by, 'Alzabo::Column' ) || Alzabo::Utils::safe_isa( $by, 'Alzabo::SQLMaker::Function' ) )
    {
        @items = $by;
    }
    elsif ( Alzabo::Utils::is_arrayref($by) )
    {
        @items = @$by;
    }

    my $method = "${type}_by";
    $sql->$method(@items);
}



__END__

=head1 NAME

Alzabo::Runtime - Loads all Alzabo::Runtime::* classes

=head1 SYNOPSIS

  use Alzabo::Runtime qw( schema_name );

=head1 DESCRIPTION

Using this module loads Alzabo::Runtime::* modules.

These modules are what an end user of Alzabo uses to instantiate
objects representing data in a given schema.

=head1 import METHOD

This method is called when you C<use> this class.  You can pass an
array of strings to the module via the C<use> function.  These strings
are assumed to be the names of schema objects that you want to load.
This can be useful if you are running under a mod_perl (or similar)
environment and has the potential to save some memory by preloading
the objects before a fork, hopefully increasing shared memory.

This method explicitly ignores errors that may occur when trying to
load a particular schema.  This means that later attempts to retrieve
that schema will probably also fail.  This is done so that the
application that wants a particular schema can explicitly handle the
failure later on.

=head1 AUTHOR

Dave Rolsky, <autarch@urth.org>

=cut