]> granicus.if.org Git - postgresql/commitdiff
Further adjustment to random() seed initialization.
authorThomas Munro <tmunro@postgresql.org>
Thu, 15 Nov 2018 04:10:43 +0000 (17:10 +1300)
committerThomas Munro <tmunro@postgresql.org>
Thu, 15 Nov 2018 04:38:55 +0000 (17:38 +1300)
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

src/backend/postmaster/postmaster.c

index 981a058522f6f54e08e73349ea9c1512adcdae2c..cb49f3255f9865387df9ef835172925f41b824f1 100644 (file)
@@ -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));
 }