From: | David Newall <davidn-postgres(at)rebel(dot)net(dot)au> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Improper processing of random values in sub-queries |
Date: | 2004-07-02 15:17:41 |
Message-ID: | 1088781410.3205.386.camel@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
PostgreSQL version: 7.4.3 (RPMs from ftp.au.postgresql.org)
Operating Sysem: Fedora Core 1
GIVEN
CREATE TABLE data (i integer);
AND
SELECT count(*), min(i), max(i) FROM data;
count | min | max
-------+-----+-----
1340 | 3 | 20
(1 row)
(Actual data attached as data.dmp)
NOW CONSIDER the following query, executed using psql:
SELECT i, j from (
SELECT i, ((i + 18 * random())::integer % 20 + 1) AS j FROM data
) foo WHERE j = 15;
Column j should be constant (15) for all rows. In fact I get the
following output:
i | j
----+----
8 | 2
8 | 1
8 | 13
8 | 5
8 | 5
9 | 19
9 | 1
10 | 8
10 | 4
11 | 5
12 | 9
19 | 10
3 | 15
3 | 16
3 | 5
3 | 18
3 | 11
3 | 10
3 | 7
3 | 13
3 | 10
3 | 18
3 | 2
.
.
.
(74 rows)
The same problem occurs for any constraint of j in the range 1..20
Attachment | Content-Type | Size |
---|---|---|
data.dmp | text/plain | 2.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2004-07-02 16:05:47 | Re: Possible bug? |
Previous Message | Peter Eisentraut | 2004-07-02 15:14:02 | Re: Grant Update (Possible bug)? |