pgsql: Increase the number of different values used when seeding random

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема pgsql: Increase the number of different values used when seeding random
Дата
Msg-id E1VZLW0-0004rZ-2T@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Increase the number of different values used when seeding random().

When a backend process is forked, we initialize the system's random number
generator with srandom(). The seed used is derived from the backend's pid
and the timestamp. However, we only used the microseconds part of the
timestamp, and it was XORed with the pid, so the total range of different
seed values chosen was 0-999999. That's quite limited.

Change the code to also use the seconds part of the timestamp in the seed,
and shift the microseconds so that all 32 bits of the seed are used.

Honza Horak

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/98c50656cac2e6b873419fd09569a9119c02148c

Modified Files
--------------
src/backend/postmaster/postmaster.c |    4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)


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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: pgsql: Improve documentation of random() function.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Use improved vsnprintf calling logic in more places.