Skip to content

Commit a113a66

Browse files
committed
Improve documentation of random() function.
Move random() and setseed() to a separate table, to have them grouped together. Also add a notice that random() is not cryptographically secure. Back-patch of commit 75fdcec into all supported versions, per discussion of the need to document that random() is just a wrapper around random(3).
1 parent 338ff75 commit a113a66

File tree

1 file changed

+50
-23
lines changed

1 file changed

+50
-23
lines changed

doc/src/sgml/func.sgml

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -650,15 +650,9 @@
650650
<indexterm>
651651
<primary>radians</primary>
652652
</indexterm>
653-
<indexterm>
654-
<primary>random</primary>
655-
</indexterm>
656653
<indexterm>
657654
<primary>round</primary>
658655
</indexterm>
659-
<indexterm>
660-
<primary>setseed</primary>
661-
</indexterm>
662656
<indexterm>
663657
<primary>sign</primary>
664658
</indexterm>
@@ -819,14 +813,6 @@
819813
<entry><literal>0.785398163397448</literal></entry>
820814
</row>
821815

822-
<row>
823-
<entry><literal><function>random()</function></literal></entry>
824-
<entry><type>dp</type></entry>
825-
<entry>random value in the range 0.0 &lt;= x &lt; 1.0</entry>
826-
<entry><literal>random()</literal></entry>
827-
<entry></entry>
828-
</row>
829-
830816
<row>
831817
<entry><literal><function>round(<type>dp</type> or <type>numeric</type>)</function></literal></entry>
832818
<entry>(same as input)</entry>
@@ -843,15 +829,6 @@
843829
<entry><literal>42.44</literal></entry>
844830
</row>
845831

846-
<row>
847-
<entry><literal><function>setseed(<type>dp</type>)</function></literal></entry>
848-
<entry><type>void</type></entry>
849-
<entry>set seed for subsequent <literal>random()</literal> calls (value between -1.0 and
850-
1.0, inclusive)</entry>
851-
<entry><literal>setseed(0.54823)</literal></entry>
852-
<entry></entry>
853-
</row>
854-
855832
<row>
856833
<entry><literal><function>sign(<type>dp</type> or <type>numeric</type>)</function></literal></entry>
857834
<entry>(same as input)</entry>
@@ -907,6 +884,56 @@
907884
</tgroup>
908885
</table>
909886

887+
<para>
888+
<xref linkend="functions-math-random-table"> shows functions for
889+
generating random numbers.
890+
</para>
891+
892+
<table id="functions-math-random-table">
893+
<title>Random Functions</title>
894+
895+
<tgroup cols="3">
896+
<thead>
897+
<row>
898+
<entry>Function</entry>
899+
<entry>Return Type</entry>
900+
<entry>Description</entry>
901+
</row>
902+
</thead>
903+
<tbody>
904+
<row>
905+
<entry>
906+
<indexterm>
907+
<primary>random</primary>
908+
</indexterm>
909+
<literal><function>random()</function></literal>
910+
</entry>
911+
<entry><type>dp</type></entry>
912+
<entry>random value in the range 0.0 &lt;= x &lt; 1.0</entry>
913+
</row>
914+
915+
<row>
916+
<entry>
917+
<indexterm>
918+
<primary>setseed</primary>
919+
</indexterm>
920+
<literal><function>setseed(<type>dp</type>)</function></literal>
921+
</entry>
922+
<entry><type>void</type></entry>
923+
<entry>set seed for subsequent <literal>random()</literal> calls (value between -1.0 and
924+
1.0, inclusive)</entry>
925+
</row>
926+
</tbody>
927+
</tgroup>
928+
</table>
929+
930+
<para>
931+
The characteristics of the values returned by
932+
<literal><function>random()</function></literal> depend
933+
on the system implementation. It is not suitable for cryptographic
934+
applications; see <xref linkend="pgcrypto"> module for an alternative.
935+
</para>
936+
910937
<para>
911938
Finally, <xref linkend="functions-math-trig-table"> shows the
912939
available trigonometric functions. All trigonometric functions

0 commit comments

Comments
 (0)