.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "DBIx::Class::SQLMaker::LimitDialects 3pm" .TH DBIx::Class::SQLMaker::LimitDialects 3pm "2022-05-21" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DBIx::Class::SQLMaker::LimitDialects \- SQL::Abstract::Limit\-like functionality in DBIx::Class::SQLMaker .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\s-1DBIC\s0's SQLMaker stack replicates and surpasses all of the functionality originally found in SQL::Abstract::Limit. While simple limits would work as-is, the more complex dialects that require e.g. subqueries could not be reliably implemented without taking full advantage of the metadata locked within DBIx::Class::ResultSource classes. After reimplementation of close to 80% of the SQL::Abstract::Limit functionality it was deemed more practical to simply make an independent DBIx::Class\-specific limit-dialect provider. .SH "SQL LIMIT DIALECTS" .IX Header "SQL LIMIT DIALECTS" Note that the actual implementations listed below never use \f(CW\*(C`*\*(C'\fR literally. Instead proper re-aliasing of selectors and order criteria is done, so that the limit dialect are safe to use on joined resultsets with clashing column names. .PP Currently the provided dialects are: .SS "LimitOffset" .IX Subsection "LimitOffset" .Vb 1 \& SELECT ... LIMIT $limit OFFSET $offset .Ve .PP Supported by \fBPostgreSQL\fR and \fBSQLite\fR .SS "LimitXY" .IX Subsection "LimitXY" .Vb 1 \& SELECT ... LIMIT $offset, $limit .Ve .PP Supported by \fBMySQL\fR and any SQL::Statement based \s-1DBD\s0 .SS "RowNumberOver" .IX Subsection "RowNumberOver" .Vb 5 \& SELECT * FROM ( \& SELECT *, ROW_NUMBER() OVER( ORDER BY ... ) AS RNO_\|_ROW_\|_INDEX FROM ( \& SELECT ... \& ) \& ) WHERE RNO_\|_ROW_\|_INDEX BETWEEN ($offset+1) AND ($limit+$offset) .Ve .PP \&\s-1ANSI\s0 standard Limit/Offset implementation. Supported by \fB\s-1DB2\s0\fR and \&\fB\s-1MSSQL\s0 >= 2005\fR. .SS "SkipFirst" .IX Subsection "SkipFirst" .Vb 1 \& SELECT SKIP $offset FIRST $limit * FROM ... .Ve .PP Supported by \fBInformix\fR, almost like LimitOffset. According to SQL::Abstract::Limit \f(CW\*(C`... SKIP $offset LIMIT $limit ...\*(C'\fR is also supported. .SS "FirstSkip" .IX Subsection "FirstSkip" .Vb 1 \& SELECT FIRST $limit SKIP $offset * FROM ... .Ve .PP Supported by \fBFirebird/Interbase\fR, reverse of SkipFirst. According to SQL::Abstract::Limit \f(CW\*(C`... ROWS $limit TO $offset ...\*(C'\fR is also supported. .SS "RowNum" .IX Subsection "RowNum" Depending on the resultset attributes one of: .PP .Vb 5 \& SELECT * FROM ( \& SELECT *, ROWNUM AS rownum_\|_index FROM ( \& SELECT ... \& ) WHERE ROWNUM <= ($limit+$offset) \& ) WHERE rownum_\|_index >= ($offset+1) .Ve .PP or .PP .Vb 5 \& SELECT * FROM ( \& SELECT *, ROWNUM AS rownum_\|_index FROM ( \& SELECT ... \& ) \& ) WHERE rownum_\|_index BETWEEN ($offset+1) AND ($limit+$offset) .Ve .PP or .PP .Vb 3 \& SELECT * FROM ( \& SELECT ... \& ) WHERE ROWNUM <= ($limit+1) .Ve .PP Supported by \fBOracle\fR. .SS "Top" .IX Subsection "Top" .Vb 1 \& SELECT * FROM \& \& SELECT TOP $limit FROM ( \& SELECT TOP $limit FROM ( \& SELECT TOP ($limit+$offset) ... \& ) ORDER BY $reversed_original_order \& ) ORDER BY $original_order .Ve .PP Unreliable Top-based implementation, supported by \fB\s-1MSSQL\s0 < 2005\fR. .PP \fI\s-1CAVEAT\s0\fR .IX Subsection "CAVEAT" .PP Due to its implementation, this limit dialect returns \fBincorrect results\fR when \f(CW$limit\fR+$offset > total amount of rows in the resultset. .SS "FetchFirst" .IX Subsection "FetchFirst" .Vb 10 \& SELECT * FROM \& ( \& SELECT * FROM ( \& SELECT * FROM ( \& SELECT * FROM ... \& ) ORDER BY $reversed_original_order \& FETCH FIRST $limit ROWS ONLY \& ) ORDER BY $original_order \& FETCH FIRST $limit ROWS ONLY \& ) .Ve .PP Unreliable FetchFirst-based implementation, supported by \fB\s-1IBM DB2\s0 <= V5R3\fR. .PP \fI\s-1CAVEAT\s0\fR .IX Subsection "CAVEAT" .PP Due to its implementation, this limit dialect returns \fBincorrect results\fR when \f(CW$limit\fR+$offset > total amount of rows in the resultset. .SS "GenericSubQ" .IX Subsection "GenericSubQ" .Vb 6 \& SELECT * FROM ( \& SELECT ... \& ) \& WHERE ( \& SELECT COUNT(*) FROM $original_table cnt WHERE cnt.id < $original_table.id \& ) BETWEEN $offset AND ($offset+$rows\-1) .Ve .PP This is the most evil limit \*(L"dialect\*(R" (more of a hack) for \fIreally\fR stupid databases. It works by ordering the set by some unique column, and calculating the amount of rows that have a less-er value (thus emulating a \*(L"RowNum\*(R"\-like index). Of course this implies the set can only be ordered by a single unique column. .PP Also note that this technique can be and often is \fBexcruciatingly slow\fR. You may have much better luck using \*(L"software_limit\*(R" in DBIx::Class::ResultSet instead. .PP Currently used by \fBSybase \s-1ASE\s0\fR, due to lack of any other option. .SH "FURTHER QUESTIONS?" .IX Header "FURTHER QUESTIONS?" Check the list of additional \s-1DBIC\s0 resources. .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This module is free software copyright by the DBIx::Class (\s-1DBIC\s0) authors. You can redistribute it and/or modify it under the same terms as the DBIx::Class library.