line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SQL::Query::Limit::MySQL; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
4055
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
59
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
75
|
|
5
|
2
|
|
|
2
|
|
9
|
use vars qw($VERSION); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
95
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$VERSION = '0.02'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
11
|
use Abstract::Meta::Class ':all'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
350
|
|
10
|
2
|
|
|
2
|
|
14
|
use SQL::Entity::Column ':all'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
210
|
|
11
|
2
|
|
|
2
|
|
12
|
use SQL::Entity::Condition ':all'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
946
|
|
12
|
2
|
|
|
2
|
|
14
|
use base 'SQL::Entity'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
683
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
SQL::Query::Limit::MySQL - LIMIT emulation for MySQL database. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
SQL::Query::Limit::Oracle |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use SQL::Query::Limit::MySQL; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
SQL navigation wrapper for MySQL. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 EXPORT |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
None. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 ATTRIBUTES |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=over |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item the_rownum |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has '$.the_rownum'; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=back |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 METHODS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=over |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item query |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub query { |
57
|
1
|
|
|
1
|
1
|
11
|
my ($self, $offset, $limit, $requested_columns, $condition) = @_; |
58
|
1
|
|
|
|
|
8
|
my ($sql, $bind_variables) = $self->SUPER::query($requested_columns, $condition); |
59
|
1
|
|
|
|
|
3
|
$sql = "SELECT " . $self->alias . ".*," . $self->the_rownum_column->as_string |
60
|
|
|
|
|
|
|
. "\nFROM (\n" . $sql . ") " . $self->alias |
61
|
|
|
|
|
|
|
. "\nLIMIT ? OFFSET ?"; |
62
|
1
|
|
|
|
|
9
|
push @$bind_variables, $limit, ($offset - 1); |
63
|
1
|
|
|
|
|
4
|
($sql, $bind_variables); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item the_rownum_column |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub the_rownum_column { |
72
|
1
|
|
|
1
|
1
|
7
|
my ($self) = @_; |
73
|
1
|
|
|
|
|
3
|
my $the_rownum = $self->the_rownum; |
74
|
1
|
|
33
|
|
|
10
|
$the_rownum ||= $self->the_rownum(SQL::Entity::Column->new(name => '@rownum = @rownum + 1', id => 'the_rownum')); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item sequence_name |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub sequence_name { |
83
|
0
|
|
|
0
|
1
|
|
'rownum'; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item query_setup |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
TODO. Improve collision in threads, |
90
|
|
|
|
|
|
|
- add ower to PLSQL |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub query_setup { |
95
|
0
|
|
|
0
|
1
|
|
my ($self, $connection) = @_; |
96
|
0
|
|
|
|
|
|
my $sequence_name = $self->sequence_name; |
97
|
0
|
|
|
|
|
|
$connection->do('SET @rownum = 1;'); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |