I'm writing a SQL script (PostgreSQL) that inserts 50k+ rows of pseudo random data into several tables using the random() function, and I wanted to know if this function is stable between operating systems. I generate many columns of data, but the gist of the script looks like:
select setseed(0.5); -- make it reproducible
select g.id, floor(random() * 1000000)::int as code
from generate_series(1, 5) g(id)
Result:
id code
-- ------
1 249910
2 520017
3 461175
4 227737
5 184899
Different members of the team may use Windows and MacOS during development, and the integration servers use Linux. Until PostgreSQL 11 the docs included the somewhat cryptic [to me] message:
The characteristics of the values returned by random() depend on the system implementation. It is not suitable for cryptographic applications; see pgcrypto module for an alternative.
So my question is, is the implementation of random() identical everywhere, or will this script generate the different data in different operating systems?
Aucun commentaire:
Enregistrer un commentaire