1DBIx::Class::SQLMaker::ULsiemritCDoinatlreicbtust(e3d)PDeBrIlx:D:oCcluamsesn:t:aStQiLoMnaker::LimitDialects(3)
2
3
4

NAME

6       DBIx::Class::SQLMaker::LimitDialects - SQL::Abstract::Limit-like
7       functionality in DBIx::Class::SQLMaker
8

DESCRIPTION

10       DBIC's SQLMaker stack replicates and surpasses all of the functionality
11       originally found in SQL::Abstract::Limit. While simple limits would
12       work as-is, the more complex dialects that require e.g. subqueries
13       could not be reliably implemented without taking full advantage of the
14       metadata locked within DBIx::Class::ResultSource classes. After
15       reimplementation of close to 80% of the SQL::Abstract::Limit
16       functionality it was deemed more practical to simply make an
17       independent DBIx::Class-specific limit-dialect provider.
18

SQL LIMIT DIALECTS

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

FURTHER QUESTIONS?

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.32.0                      2020-0D7B-I2x8::Class::SQLMaker::LimitDialects(3)
Impressum