mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
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
This commit is contained in:
@ -26,8 +26,9 @@ ERROR: unrecognized parameter "not_existing_option"
|
||||
CREATE TABLE reloptions_test2(i INT) WITH (not_existing_namespace.fillfactor=2);
|
||||
ERROR: unrecognized parameter namespace "not_existing_namespace"
|
||||
-- Fail while setting improper values
|
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=30.5);
|
||||
ERROR: invalid value for integer option "fillfactor": 30.5
|
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=-30.1);
|
||||
ERROR: value -30.1 out of bounds for option "fillfactor"
|
||||
DETAIL: Valid values are between "10" and "100".
|
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor='string');
|
||||
ERROR: invalid value for integer option "fillfactor": string
|
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=true);
|
||||
|
@ -15,7 +15,7 @@ CREATE TABLE reloptions_test2(i INT) WITH (not_existing_option=2);
|
||||
CREATE TABLE reloptions_test2(i INT) WITH (not_existing_namespace.fillfactor=2);
|
||||
|
||||
-- Fail while setting improper values
|
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=30.5);
|
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=-30.1);
|
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor='string');
|
||||
CREATE TABLE reloptions_test2(i INT) WITH (fillfactor=true);
|
||||
CREATE TABLE reloptions_test2(i INT) WITH (autovacuum_enabled=12);
|
||||
|
Reference in New Issue
Block a user