Re: random generated string matching index in inexplicable ways

From: Myles Miller <pg(at)q7r7(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: random generated string matching index in inexplicable ways
Date: 2019-05-07 13:12:36
Message-ID: 20190507131236.GA62383@50pop.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> > # SELECT y FROM x WHERE y = chr(round(random())::int + 65);
> > y
> > ---
> > A
> > B
> > (2 rows)
> Here you got a random value in the lower range of 0..1 for the record with value ‘A’, so that’s a match, and one in the higher range for value ‘B’, a match again, so you get 2 rows.

No, the function is returning just one letter, either 'A' or 'B', not multiple values.

# SELECT * FROM chr(round(random())::int + 65);
chr
-----
B
(1 row)

# SELECT * FROM chr(round(random())::int + 65);
chr
-----
A
(1 row)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Myles Miller 2019-05-07 13:15:12 Re: random generated string matching index in inexplicable ways [EXT]
Previous Message Alban Hertroys 2019-05-07 12:50:31 Re: random generated string matching index in inexplicable ways