We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
random()
Handy for generating testing data.
No response
The text was updated successfully, but these errors were encountered:
The corresponding setseed function seems non-trivial. Note the following query is actually deterministic:
setseed
test=# select case n when 1 then setseed(0.4) else null end, random() from generate_series(1, 10) as t(n); case | random ------+--------------------- | 0.6722690410337004 | 0.9936586191615264 | 0.19947461195735405 | 0.90340354600701 | 0.516998156895498 | 0.7913052710048887 | 0.531550972556847 | 0.48302401286537666 | 0.14525565255427209 | 0.19221106009513123 (10 rows)
So what random() really does in PostgreSQL is mutating a session-level variable: https://www.postgresql.org/docs/16/sql-set.html#:~:text=TO%20value.-,SEED,-Sets%20the%20internal https://github.com/postgres/postgres/blob/REL_16_1/src/backend/utils/misc/guc_tables.c#L3695-L3704 https://github.com/postgres/postgres/blob/REL_16_1/src/common/pg_prng.c#L232-L234
Of course we can provide a weaker random() function first without the ability to generate deterministic sequence given a seed.
cc @wangrunji0408 may be more familiar with RNGs given experience working on madsim.
Sorry, something went wrong.
So what random() really does in PostgreSQL is mutating a session-level variable:
Either LGTM. If the session-level variable approach involves lots of work, I will prefer the 2nd
wangrunji0408
No branches or pull requests
Is your feature request related to a problem? Please describe.
Handy for generating testing data.
Describe the solution you'd like
No response
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: