/usr/share/perl5/Tangram/Expr/Select.pm is in libtangram-perl 2.10-2.
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 | package Tangram::Expr::Select;
use strict;
use Tangram::Expr::Filter;
use Carp;
use vars qw(@ISA);
@ISA = qw( Tangram::Expr );
sub new
{
my ($type, %args) = @_;
my $cols = join ', ', map
{
confess "column specification must be a Tangram::Expr" unless $_->isa('Tangram::Expr');
$_->{expr};
} @{$args{cols}};
my $filter = $args{filter} || $args{where} || Tangram::Expr::Filter->new;
my $objects = Set::Object->new();
if (exists $args{from})
{
$objects->insert( map { $_->object } @{ $args{from} } );
}
else
{
$objects->insert( $filter->objects(), map { $_->objects } @{ $args{cols} } );
$objects->remove( @{ $args{exclude} } ) if exists $args{exclude};
}
my $from = join ', ', map { $_->from } $objects->members;
my $where = join ' AND ',
$filter->{expr} ? "($filter->{expr})" : (),
map { $_->where } $objects->members;
my $sql = "SELECT";
$sql .= ' DISTINCT' if $args{distinct};
$sql .= " $cols";
if (exists $args{order}) {
$sql .= join("", map {", $_"}
grep { $sql !~ m/ \Q$_\E(?:,|$)/ }
map { $_->{expr} } @{$args{order}});
}
$sql .= "\nFROM $from" if $from;
$sql .= "\nWHERE $where" if $where;
if (exists $args{order})
{
$sql .= "\nORDER BY " . join ', ', map { $_->{expr} } @{$args{order}};
}
my $self = $type->SUPER::new(Tangram::Type::Integer->instance, "($sql)");
$self->{cols} = $args{cols};
return $self;
}
sub from
{
my ($self) = @_;
my $from = $self->{from};
return $from ? $from->members : $self->SUPER::from;
}
sub where
{
}
sub execute
{
my ($self, $storage, $conn) = @_;
return Tangram::Cursor::Data->open($storage, $self, $conn);
}
1;
|