1DBIx::Class::SQLMaker::ULsiemritCDoinatlreicbtust(e3d)PDeBrIlx:D:oCcluamsesn:t:aStQiLoMnaker::LimitDialects(3)
2
3
4
6 DBIx::Class::SQLMaker::LimitDialects - SQL::Abstract::Limit-like
7 functionality for DBIx::Class::SQLMaker
8
10 This module replicates a lot of the functionality originally found in
11 SQL::Abstract::Limit. While simple limits would work as-is, the more
12 complex dialects that require e.g. subqueries could not be reliably
13 implemented without taking full advantage of the metadata locked within
14 DBIx::Class::ResultSource classes. After reimplementation of close to
15 80% of the SQL::Abstract::Limit functionality it was deemed more
16 practical to simply make an independent DBIx::Class-specific limit-
17 dialect provider.
18
20 Note that the actual implementations listed below never use "*"
21 literally. Instead proper re-aliasing of selectors and order criteria
22 is done, so that the limit dialect are safe to use on joined resultsets
23 with clashing column names.
24
25 Currently the provided dialects are:
26
27 LimitOffset
28 SELECT ... LIMIT $limit OFFSET $offset
29
30 Supported by PostgreSQL and SQLite
31
32 LimitXY
33 SELECT ... LIMIT $offset, $limit
34
35 Supported by MySQL and any SQL::Statement based DBD
36
37 RowNumberOver
38 SELECT * FROM (
39 SELECT *, ROW_NUMBER() OVER( ORDER BY ... ) AS RNO__ROW__INDEX FROM (
40 SELECT ...
41 )
42 ) WHERE RNO__ROW__INDEX BETWEEN ($offset+1) AND ($limit+$offset)
43
44 ANSI standard Limit/Offset implementation. Supported by DB2 and MSSQL
45 >= 2005.
46
47 SkipFirst
48 SELECT SKIP $offset FIRST $limit * FROM ...
49
50 Supported by Informix, almost like LimitOffset. According to
51 SQL::Abstract::Limit "... SKIP $offset LIMIT $limit ..." is also
52 supported.
53
54 FirstSkip
55 SELECT FIRST $limit SKIP $offset * FROM ...
56
57 Supported by Firebird/Interbase, reverse of SkipFirst. According to
58 SQL::Abstract::Limit "... ROWS $limit TO $offset ..." is also
59 supported.
60
61 RowNum
62 Depending on the resultset attributes one of:
63
64 SELECT * FROM (
65 SELECT *, ROWNUM AS rownum__index FROM (
66 SELECT ...
67 ) WHERE ROWNUM <= ($limit+$offset)
68 ) WHERE rownum__index >= ($offset+1)
69
70 or
71
72 SELECT * FROM (
73 SELECT *, ROWNUM AS rownum__index FROM (
74 SELECT ...
75 )
76 ) WHERE rownum__index BETWEEN ($offset+1) AND ($limit+$offset)
77
78 or
79
80 SELECT * FROM (
81 SELECT ...
82 ) WHERE ROWNUM <= ($limit+1)
83
84 Supported by Oracle.
85
86 Top
87 SELECT * FROM
88
89 SELECT TOP $limit FROM (
90 SELECT TOP $limit FROM (
91 SELECT TOP ($limit+$offset) ...
92 ) ORDER BY $reversed_original_order
93 ) ORDER BY $original_order
94
95 Unreliable Top-based implementation, supported by MSSQL < 2005.
96
97 CAVEAT
98
99 Due to its implementation, this limit dialect returns incorrect results
100 when $limit+$offset > total amount of rows in the resultset.
101
102 FetchFirst
103 SELECT * FROM
104 (
105 SELECT * FROM (
106 SELECT * FROM (
107 SELECT * FROM ...
108 ) ORDER BY $reversed_original_order
109 FETCH FIRST $limit ROWS ONLY
110 ) ORDER BY $original_order
111 FETCH FIRST $limit ROWS ONLY
112 )
113
114 Unreliable FetchFirst-based implementation, supported by IBM DB2 <=
115 V5R3.
116
117 CAVEAT
118
119 Due to its implementation, this limit dialect returns incorrect results
120 when $limit+$offset > total amount of rows in the resultset.
121
122 GenericSubQ
123 SELECT * FROM (
124 SELECT ...
125 )
126 WHERE (
127 SELECT COUNT(*) FROM $original_table cnt WHERE cnt.id < $original_table.id
128 ) BETWEEN $offset AND ($offset+$rows-1)
129
130 This is the most evil limit "dialect" (more of a hack) for really
131 stupid databases. It works by ordering the set by some unique column,
132 and calculating the amount of rows that have a less-er value (thus
133 emulating a "RowNum"-like index). Of course this implies the set can
134 only be ordered by a single unique column.
135
136 Also note that this technique can be and often is excruciatingly slow.
137 You may have much better luck using "software_limit" in
138 DBIx::Class::ResultSet instead.
139
140 Currently used by Sybase ASE, due to lack of any other option.
141
143 Check the list of additional DBIC resources.
144
146 This module is free software copyright by the DBIx::Class (DBIC)
147 authors. You can redistribute it and/or modify it under the same terms
148 as the DBIx::Class library.
149
150
151
152perl v5.30.1 2020-0D1B-I2x9::Class::SQLMaker::LimitDialects(3)