From 1aab783b59d56af304cd652d2036ba45769122ec Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sun, 23 Sep 2001 03:39:01 +0000 Subject: Implement TODO item: * Change LIMIT val,val to offset,limit to match MySQL Documentation updates too. --- doc/src/sgml/ref/select.sgml | 20 ++++++++++++-------- doc/src/sgml/sql.sgml | 5 +++-- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/select.sgml b/doc/src/sgml/ref/select.sgml index 2e1e552f264..e8dc02498ca 100644 --- a/doc/src/sgml/ref/select.sgml +++ b/doc/src/sgml/ref/select.sgml @@ -1,5 +1,5 @@ @@ -29,7 +29,8 @@ SELECT [ ALL | DISTINCT [ ON ( expressionselect ] [ ORDER BY expression [ ASC | DESC | USING operator ] [, ...] ] [ FOR UPDATE [ OF tablename [, ...] ] ] - [ LIMIT { count | ALL } [ { OFFSET | , } start ]] + [ LIMIT [ start , ] { count | ALL } ] + [ OFFSET start ] where from_item can be: @@ -613,7 +614,8 @@ SELECT name FROM distributors ORDER BY code; table_query UNION [ ALL ] table_query [ ORDER BY expression [ ASC | DESC | USING operator ] [, ...] ] - [ LIMIT { count | ALL } [ { OFFSET | , } start ]] + [ LIMIT [ start , ] { count | ALL } ] + [ OFFSET start ] where @@ -662,7 +664,8 @@ SELECT name FROM distributors ORDER BY code; table_query INTERSECT [ ALL ] table_query [ ORDER BY expression [ ASC | DESC | USING operator ] [, ...] ] - [ LIMIT { count | ALL } [ { OFFSET | , } start ]] + [ LIMIT [ start , ] { count | ALL } ] + [ OFFSET start ] where @@ -702,7 +705,8 @@ SELECT name FROM distributors ORDER BY code; table_query EXCEPT [ ALL ] table_query [ ORDER BY expression [ ASC | DESC | USING operator ] [, ...] ] - [ LIMIT { count | ALL } [ { OFFSET | , } start ]] + [ LIMIT [ start , ] { count | ALL } ] + [ OFFSET start ] where @@ -738,7 +742,7 @@ SELECT name FROM distributors ORDER BY code; - LIMIT { count | ALL } [ { OFFSET | , } start ] + LIMIT [ start , ] { count | ALL } OFFSET start @@ -761,14 +765,14 @@ SELECT name FROM distributors ORDER BY code; constrains the result rows into a unique order. Otherwise you will get an unpredictable subset of the query's rows---you may be asking for the tenth through twentieth rows, but tenth through twentieth in what - ordering? You don't know what ordering, unless you specified ORDER BY. + ordering? You don't know what ordering unless you specify ORDER BY. As of Postgres 7.0, the query optimizer takes LIMIT into account when generating a query plan, so you are very likely to get different plans (yielding different row - orders) depending on what you give for LIMIT and OFFSET. Thus, using + orders) depending on what you use for LIMIT and OFFSET. Thus, using different LIMIT/OFFSET values to select different subsets of a query result will give inconsistent results unless you enforce a predictable result ordering with ORDER BY. This is not diff --git a/doc/src/sgml/sql.sgml b/doc/src/sgml/sql.sgml index d0eef867abf..223aee1bc69 100644 --- a/doc/src/sgml/sql.sgml +++ b/doc/src/sgml/sql.sgml @@ -1,5 +1,5 @@ @@ -864,7 +864,8 @@ SELECT [ ALL | DISTINCT [ ON ( expressionselect ] [ ORDER BY expression [ ASC | DESC | USING operator ] [, ...] ] [ FOR UPDATE [ OF class_name [, ...] ] ] - [ LIMIT { count | ALL } [ { OFFSET | , } start ]] + [ LIMIT [ start , ] { count | ALL } ] + [ OFFSET start ] -- cgit v1.2.3