8000 Further adjustment to random() seed initialization. · postgrespro/postgres@ab8984f · GitHub
[go: up one dir, main page]

Skip to content

Commit ab8984f

Browse files
committed
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
1 parent 5b0ce3e commit ab8984f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 3 additions & 3 deletions
< 5B0C td data-grid-cell-id="diff-f645f6cb33adf635a60fbaba0e095b75112ddd0b14468c14058e96bbbd33a58a-2537-2534-2" data-line-anchor="diff-f645f6cb33adf635a60fbaba0e095b75112ddd0b14468c14058e96bbbd33a58aL2537" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-deletionLine-bgColor, var(--diffBlob-deletion-bgColor-line));padding-right:24px" tabindex="-1" valign="top" class="focusable-grid-cell diff-text-cell left-side-diff-cell border-right left-side">-
((unsigned int) MyStartTimestamp >> 20));
Original file line numberDiff line numberDiff line change
@@ -2532,9 +2532,9 @@ InitProcessGlobals(void)
25322532
* in a given time period. Since that would leave only 20 bits of the
25332533
* timestamp that cycle every ~1 second, also mix in some higher bits.
25342534
*/
2535-
srandom(((unsigned int) MyProcPid) ^
2536-
((unsigned int) MyStartTimestamp << 12) ^
2537
2535+
srandom(((uint64) MyProcPid) ^
2536+
((uint64) MyStartTimestamp << 12) ^
2537+
((uint64) MyStartTimestamp >> 20));
25382538
}
25392539

25402540

0 commit comments

Comments
 (0)
0