From: | Gianni Ciolli <gianni(dot)ciolli(at)2ndquadrant(dot)it> |
---|---|
To: | Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Transforming IN (...) to ORs, volatility |
Date: | 2011-04-01 12:08:51 |
Message-ID: | 20110401120850.GH6543@albo.gi.lan |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Apr 01, 2011 at 02:24:53PM +0300, Heikki Linnakangas wrote:
> I tried to read the SQL spec to see if it has anything to say about
> that, but I couldn't find anything. My common sense says that that
> transformation is not legal.
Your feeling is correct; I would motivate it as follows.
random() IN (b,c)
is not equivalent to
(random() = b) OR (random() = c)
because the two random() will evaluate to two different numbers. So,
for instance, if you define random_boolean() as either true or false
randomly (and VOLATILEly), then
random_boolean() IN (true, false)
is always true, while
(random_boolean() = true) OR (random_boolean() = false)
is not (has probability 75%). For instance, the first random_boolean()
might return false while the second one returns true.
Best regards,
Dr. Gianni Ciolli - 2ndQuadrant Italia
PostgreSQL Training, Services and Support
gianni(dot)ciolli(at)2ndquadrant(dot)it | www.2ndquadrant.it
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2011-04-01 12:13:34 | Re: Should psql support URI syntax? |
Previous Message | Shigeru HANADA | 2011-04-01 11:57:14 | Re: Foreign table permissions and cloning |