diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-03-11 19:13:46 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-03-11 19:13:55 -0400 |
commit | 1a83a80a2fe5b559f85ed4830acb92d5124b7a9a (patch) | |
tree | d6dd443a20eef9147572f430a707308f8326eab7 /doc/src | |
parent | fe0b2c12c992fa44ca0448bde9099957306c843f (diff) | |
download | postgresql-1a83a80a2fe5b559f85ed4830acb92d5124b7a9a.tar.gz postgresql-1a83a80a2fe5b559f85ed4830acb92d5124b7a9a.zip |
Allow fractional input values for integer GUCs, and improve rounding logic.
Historically guc.c has just refused examples like set work_mem = '30.1GB',
but it seems more useful for it to take that and round off the value to
some reasonable approximation of what the user said. Just rounding to
the parameter's native unit would work, but it would lead to rather
silly-looking settings, such as 31562138kB for this example. Instead
let's round to the nearest multiple of the next smaller unit (if any),
producing 30822MB.
Also, do the units conversion math in floating point and round to integer
(if needed) only at the end. This produces saner results for inputs that
aren't exact multiples of the parameter's native unit, and removes another
difference in the behavior for integer vs. float parameters.
In passing, document the ability to use hex or octal input where it
ought to be documented.
Discussion: https://postgr.es/m/1798.1552165479@sss.pgh.pa.us
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/config.sgml | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index fe1735722a6..d383de25128 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -51,14 +51,21 @@ In general, enclose the value in single quotes, doubling any single quotes within the value. Quotes can usually be omitted if the value is a simple number or identifier, however. + (Values that match a SQL keyword require quoting in some contexts.) </para> </listitem> <listitem> <para> <emphasis>Numeric (integer and floating point):</emphasis> - A decimal point is permitted only for floating-point parameters. - Do not use thousands separators. Quotes are not required. + Numeric parameters can be specified in the customary integer and + floating-point formats; fractional values are rounded to the nearest + integer if the parameter is of integer type. Integer parameters + additionally accept hexadecimal input (beginning + with <literal>0x</literal>) and octal input (beginning + with <literal>0</literal>), but these formats cannot have a fraction. + Do not use thousands separators. + Quotes are not required, except for hexadecimal input. </para> </listitem> @@ -99,6 +106,13 @@ </para> </listitem> </itemizedlist> + + If a fractional value is specified with a unit, it will be rounded + to a multiple of the next smaller unit if there is one. + For example, <literal>30.1 GB</literal> will be converted + to <literal>30822 MB</literal> not <literal>32319628902 B</literal>. + If the parameter is of integer type, a final rounding to integer + occurs after any units conversion. </para> </listitem> |