| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package DBIx::SearchBuilder::Handle::Informix; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1253
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
31
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
31
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw(DBIx::SearchBuilder::Handle); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
726
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
DBIx::SearchBuilder::Handle::Informix - An Informix specific Handle object |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
This module provides a subclass of DBIx::SearchBuilder::Handle that |
|
18
|
|
|
|
|
|
|
compensates for some of the idiosyncrasies of Informix. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 METHODS |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 Insert |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Takes a table name as the first argument and assumes that the rest of the arguments are an array of key-value pairs to be inserted. |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
If the insert succeeds, returns the id of the insert, otherwise, returns |
|
30
|
|
|
|
|
|
|
a Class::ReturnValue object with the error reported. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub Insert { |
|
35
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $sth = $self->SUPER::Insert(@_); |
|
38
|
0
|
0
|
|
|
|
|
if (!$sth) { |
|
39
|
0
|
|
|
|
|
|
print "no sth! (".$self->dbh->{ix_sqlerrd}[1].")\n"; |
|
40
|
0
|
|
|
|
|
|
return ($sth); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$self->{id}=$self->dbh->{ix_sqlerrd}[1]; |
|
45
|
0
|
0
|
|
|
|
|
warn "$self no row id returned on row creation" unless ($self->{'id'}); |
|
46
|
0
|
|
|
|
|
|
return( $self->{'id'}); #Add Succeded. return the id |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 CaseSensitive |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Returns 1, since Informix's searches are case sensitive by default |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub CaseSensitive { |
|
57
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
58
|
0
|
|
|
|
|
|
return(1); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 BuildDSN |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Builder for Informix DSNs. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub BuildDSN { |
|
69
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
70
|
0
|
|
|
|
|
|
my %args = ( |
|
71
|
|
|
|
|
|
|
Driver => undef, |
|
72
|
|
|
|
|
|
|
Database => undef, |
|
73
|
|
|
|
|
|
|
Host => undef, |
|
74
|
|
|
|
|
|
|
Port => undef, |
|
75
|
|
|
|
|
|
|
SID => undef, |
|
76
|
|
|
|
|
|
|
RequireSSL => undef, |
|
77
|
|
|
|
|
|
|
@_ |
|
78
|
|
|
|
|
|
|
); |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
my $dsn = "dbi:$args{'Driver'}:"; |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
0
|
0
|
|
|
|
$dsn .= "$args{'Database'}" if (defined $args{'Database'} && $args{'Database'}); |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
$self->{'dsn'}= $dsn; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 ApplyLimits STATEMENTREF ROWS_PER_PAGE FIRST_ROW |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
takes an SQL SELECT statement and massages it to return ROWS_PER_PAGE starting with FIRST_ROW; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub ApplyLimits { |
|
96
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
97
|
0
|
|
|
|
|
|
my $statementref = shift; |
|
98
|
0
|
|
|
|
|
|
my $per_page = shift; |
|
99
|
0
|
|
|
|
|
|
my $first = shift; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# XXX TODO THIS only works on the FIRST page of results. that's a bug |
|
102
|
0
|
0
|
|
|
|
|
if ($per_page) { |
|
103
|
0
|
|
|
|
|
|
$$statementref =~ s[^\s*SELECT][SELECT FIRST $per_page]i; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub Disconnect { |
|
109
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
110
|
0
|
0
|
|
|
|
|
if ($self->dbh) { |
|
111
|
0
|
|
|
|
|
|
my $status = $self->dbh->disconnect(); |
|
112
|
0
|
|
|
|
|
|
$self->dbh( undef); |
|
113
|
0
|
|
|
|
|
|
return $status; |
|
114
|
|
|
|
|
|
|
} else { |
|
115
|
0
|
|
|
|
|
|
return; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 DistinctQuery STATEMENTREF |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
takes an incomplete SQL SELECT statement and massages it to return a DISTINCT result set. |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub DistinctQuery { |
|
128
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
129
|
0
|
|
|
|
|
|
my $statementref = shift; |
|
130
|
0
|
|
|
|
|
|
my $sb = shift; |
|
131
|
0
|
|
|
|
|
|
my $table = $sb->Table; |
|
132
|
|
|
|
|
|
|
|
|
133
|
0
|
0
|
|
|
|
|
if ($sb->_OrderClause =~ /(?
|
|
134
|
|
|
|
|
|
|
# Don't know how to do ORDER BY when the DISTINCT is in a subquery |
|
135
|
0
|
|
|
|
|
|
warn "Query will contain duplicate rows; don't how how to ORDER BY across DISTINCT"; |
|
136
|
0
|
|
|
|
|
|
$$statementref = "SELECT main.* FROM $$statementref"; |
|
137
|
|
|
|
|
|
|
} else { |
|
138
|
|
|
|
|
|
|
# Wrapper select query in a subselect as Informix doesn't allow |
|
139
|
|
|
|
|
|
|
# DISTINCT against CLOB/BLOB column types. |
|
140
|
0
|
|
|
|
|
|
$$statementref = "SELECT * FROM $table main WHERE id IN ( SELECT DISTINCT main.id FROM $$statementref )"; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
0
|
|
|
|
|
|
$$statementref .= $sb->_GroupClause; |
|
143
|
0
|
|
|
|
|
|
$$statementref .= $sb->_OrderClause; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |