Re: Transforming IN (...) to ORs, volatility

Поиск
Список
Период
Сортировка
От Gianni Ciolli
Тема Re: Transforming IN (...) to ORs, volatility
Дата
Msg-id 20110401120850.GH6543@albo.gi.lan
обсуждение исходный текст
Ответ на Transforming IN (...) to ORs, volatility  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
Список 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.ciolli@2ndquadrant.it | www.2ndquadrant.it


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Shigeru HANADA
Дата:
Сообщение: Re: Foreign table permissions and cloning
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: Should psql support URI syntax?