From: | Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com> |
---|---|
To: | Reg Me Please <regmeplease(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org, Peter Eisentraut <peter_e(at)gmx(dot)net>, Gregory Stark <stark(at)enterprisedb(dot)com> |
Subject: | Re: Pet Peeves? |
Date: | 2009-01-30 13:52:45 |
Message-ID: | 2f4958ff0901300552w120ed444n935a2352baf31a0e@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Jan 30, 2009 at 1:37 PM, Reg Me Please <regmeplease(at)gmail(dot)com> wrote:
> * LIMIT and OFFSET don't accept non-constant (or non function) values
>
no longer true with 8.4
gjaskie=# create table foo(a serial, b varchar);
gjaskie=# insert into table foo(b) select generate_series(1,10000,
(random()*100)::int);
gjaskie=# insert into foo(b) select generate_series(1,10000,
(random()*100)::int);
gjaskie=# insert into foo(b) select generate_series(1,10000,
(random()*100)::int);
gjaskie=# insert into foo(b) select generate_series(1,10000,
(random()*100)::int);
gjaskie=# select count(*) from foo;
count
-------
2019
(1 row)
gjaskie=# select * from foo order by random() limit (select a*random()
from foo order by random() limit 1);
a | b
------+------
1491 | 8941
892 | 5347
1609 | 9649
1796 | 9985
190 | 1135
1445 | 8665
194 | 1159
47 | 277
911 | 5461
1941 | 6481
196 | 1171
1995 | 8911
25 | 145
1430 | 8575
533 | 3193
172 | 1027
1111 | 6661
948 | 5683
148 | 883
99 | 589
173 | 1033
1224 | 7339
973 | 5833
1358 | 8143
1532 | 9187
165 | 985
1996 | 8956
82 | 487
820 | 4915
1185 | 7105
534 | 3199
57 | 337
2019 | 9991
(33 rows)
gjaskie=# select version();
version
--------------------------------------------------------------------------------------------------------------
PostgreSQL 8.4devel on i686-pc-linux-gnu, compiled by GCC gcc (GCC)
4.3.0 20080428 (Red Hat 4.3.0-8), 32-bit
(1 row)
--
GJ
From | Date | Subject | |
---|---|---|---|
Next Message | Grzegorz Jaśkiewicz | 2009-01-30 14:00:31 | Re: need contact in Nepal |
Previous Message | Reg Me Please | 2009-01-30 13:37:13 | Re: Pet Peeves? |