Struct SqlRowLimit
- Namespace
- Quartz.Impl.AdoJobStore
- Assembly
- Quartz.dll
How a dialect says "at most this many rows", as a slot the statement has for it rather than as an edit to finished SQL.
public readonly record struct SqlRowLimit : IEquatable<SqlRowLimit>
- Implements
- Inherited Members
Remarks
There is no ANSI row limit, so every database spells it somewhere else in the statement, and a
dialect used to reach into a statement it does not own to put it there — SQL Server cut the first
six characters off and pasted its own SELECT back on, which was correct only while the
statement began with exactly that keyword and nothing said it had to. A dialect now says which of
the three places its clause belongs in, and the statement is built with it already there.
The three cover every shipped dialect and, as far as row limiting goes, every SQL database:
InProjection(string, int) for SQL Server's TOP, AtStatementEnd(string, int) for the
LIMIT of PostgreSQL, MySQL and SQLite and the ROWS of Firebird, and
InEnclosingSelect(string, int) for Oracle's rownum.
The count is spliced into the text rather than bound as a parameter, because a row limit is part
of the statement's shape on several of these databases — SQL Server will not take TOP from
a parameter without parentheses, and a limit that varies per call would churn the plan cache
anyway. The value is Quartz's own batch size, never anything a caller supplies.
Properties
Unlimited
No limit at all: the statement is built exactly as it would be for a database that cannot limit rows, which is what StdAdoDelegate itself assumes.
public static SqlRowLimit Unlimited { get; }
Property Value
Methods
AtStatementEnd(string, int)
A limit that follows the whole statement, after its ORDER BY — … LIMIT 5.
public static SqlRowLimit AtStatementEnd(string keyword, int count)
Parameters
keywordstringThe keyword introducing the limit:
LIMITon PostgreSQL, MySQL and SQLite,ROWSon Firebird.countintThe most rows the statement may return.
Returns
InEnclosingSelect(string, int)
A limit expressed by an enclosing SELECT that filters on a row-number pseudo-column —
SELECT * FROM (…) WHERE rownum <= 5.
public static SqlRowLimit InEnclosingSelect(string pseudoColumn, int count)
Parameters
pseudoColumnstringThe pseudo-column carrying the row number,
rownumon Oracle.countintThe most rows the statement may return.
Returns
InProjection(string, int)
A limit that sits in the projection, immediately after the SELECT keyword —
SELECT TOP 5 ….
public static SqlRowLimit InProjection(string keyword, int count)
Parameters
keywordstringThe keyword introducing the limit,
TOPon SQL Server.countintThe most rows the statement may return.