From: Thomas Munro Date: Thu, 15 Nov 2018 04:10:43 +0000 (+1300) Subject: Further adjustment to random() seed initialization. X-Git-Tag: REL_12_BETA1~1233 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ab8984f52d9b99234d23e6fb7b73cf4c12b3ac14;p=postgresql Further adjustment to random() seed initialization. Per complaint from Tom Lane, don't chomp the timestamp at 32 bits, so we can shift in some of its higher bits. Discussion: https://postgr.es/m/14712.1542253115%40sss.pgh.pa.us --- diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 981a058522..cb49f3255f 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -2532,9 +2532,9 @@ InitProcessGlobals(void) * in a given time period. Since that would leave only 20 bits of the * timestamp that cycle every ~1 second, also mix in some higher bits. */ - srandom(((unsigned int) MyProcPid) ^ - ((unsigned int) MyStartTimestamp << 12) ^ - ((unsigned int) MyStartTimestamp >> 20)); + srandom(((uint64) MyProcPid) ^ + ((uint64) MyStartTimestamp << 12) ^ + ((uint64) MyStartTimestamp >> 20)); }