From: Myles Miller <pg@q7r7.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: random generated string matching index in inexplicable ways
Date: Tue, 7 May 2019 09:12:36 -0400
Message-ID: <20190507131236.GA62383@50pop.com> (raw)
In-Reply-To: <D663E9E1-C50D-41AC-8432-27A73C1C6F9D@gmail.com>
References: <20190507115345.GA56585@50pop.com>
<D663E9E1-C50D-41AC-8432-27A73C1C6F9D@gmail.com>
> > # 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)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: pg@q7r7.com
Subject: Re: random generated string matching index in inexplicable ways
In-Reply-To: <20190507131236.GA62383@50pop.com>
References: <20190507115345.GA56585@50pop.com> <D663E9E1-C50D-41AC-8432-27A73C1C6F9D@gmail.com> <20190507131236.GA62383@50pop.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox