mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-12 04:16:50 +02:00
b11123b675
recompute the limit/offset immediately, so that the updated values are available when the child's ReScan function is invoked. Add a regression test for this, too. Bug is new in HEAD (due to the bounded-sorting patch) so no need for back-patch. I did not do anything about merging this signaling with chgParam processing, but if we were to do that we'd still need to compute the updated values at this point rather than during the first ProcNode call. Per observation and test case from Greg Stark, though I didn't use his patch.
42 lines
1.3 KiB
SQL
42 lines
1.3 KiB
SQL
--
|
|
-- LIMIT
|
|
-- Check the LIMIT/OFFSET feature of SELECT
|
|
--
|
|
|
|
SELECT ''::text AS two, unique1, unique2, stringu1
|
|
FROM onek WHERE unique1 > 50
|
|
ORDER BY unique1 LIMIT 2;
|
|
SELECT ''::text AS five, unique1, unique2, stringu1
|
|
FROM onek WHERE unique1 > 60
|
|
ORDER BY unique1 LIMIT 5;
|
|
SELECT ''::text AS two, unique1, unique2, stringu1
|
|
FROM onek WHERE unique1 > 60 AND unique1 < 63
|
|
ORDER BY unique1 LIMIT 5;
|
|
SELECT ''::text AS three, unique1, unique2, stringu1
|
|
FROM onek WHERE unique1 > 100
|
|
ORDER BY unique1 LIMIT 3 OFFSET 20;
|
|
SELECT ''::text AS zero, unique1, unique2, stringu1
|
|
FROM onek WHERE unique1 < 50
|
|
ORDER BY unique1 DESC LIMIT 8 OFFSET 99;
|
|
SELECT ''::text AS eleven, unique1, unique2, stringu1
|
|
FROM onek WHERE unique1 < 50
|
|
ORDER BY unique1 DESC LIMIT 20 OFFSET 39;
|
|
SELECT ''::text AS ten, unique1, unique2, stringu1
|
|
FROM onek
|
|
ORDER BY unique1 OFFSET 990;
|
|
SELECT ''::text AS five, unique1, unique2, stringu1
|
|
FROM onek
|
|
ORDER BY unique1 OFFSET 990 LIMIT 5;
|
|
SELECT ''::text AS five, unique1, unique2, stringu1
|
|
FROM onek
|
|
ORDER BY unique1 LIMIT 5 OFFSET 900;
|
|
|
|
-- Stress test for variable LIMIT in conjunction with bounded-heap sorting
|
|
|
|
SELECT
|
|
(SELECT n
|
|
FROM (VALUES (1)) AS x,
|
|
(SELECT n FROM generate_series(1,10) AS n
|
|
ORDER BY n LIMIT 1 OFFSET s-1) AS y) AS z
|
|
FROM generate_series(1,10) AS s;
|