Strange behavior of the random() function - Mailing list pgsql-general

From r.zharkov@postgrespro.ru
Subject Strange behavior of the random() function
Date
Msg-id 00b2388c8e5a8d1dfb693d2b59b00722@postgrespro.ru
Whole thread Raw
Responses Re: Strange behavior of the random() function
List pgsql-general
Hello,
Can anybody explain me that strange behavior?

  select random() as "rnd", random() as "rnd1", random() as "rnd2"
  from generate_series( 1, 5 );
  ---
  0.948556384071708    0.769186236895621    0.381390900816768
  0.684488877654076    0.594888080842793    0.214444123208523
  0.668408528901637    0.452859566546977    0.924952184315771

All of the values are different.

  select random() as "rnd", random() as "rnd1", random() as "rnd2"
  from generate_series( 1, 3 )
  order by random();
  ---
  0.166236794553697    0.166236794553697    0.166236794553697
  0.629051928408444    0.629051928408444    0.629051928408444
  0.698161978274584    0.698161978274584    0.698161978274584

All values in any row are the same.

  select random() as "rnd", random() as "rnd1", random() as "rnd2"
  from generate_series( 1, 3 )
  order by random() || 'test';
  ---
  0.569052047561854    0.531697370111942    0.338135569822043
  0.880468992516398    0.172520748339593    0.0296505615115166
  0.862012444529682    0.119546371512115    0.21626165881753

All of the values are different again.

Is it a bug?


pgsql-general by date:

Previous
From: Christopher Browne
Date:
Subject: Re: Weird procedure question
Next
From: Tom Lane
Date:
Subject: Re: Strange behavior of the random() function