Skip to content

enable_alternative_round (boolean)

The second argument (decimal places) of the ROUND function requires a constant value; column values are not allowed. Disallowing a column value for the second parameter enables optimization of function execution ahead of time, but it can break compatibility with SQL queries or workloads that require this.

By setting this parameter to ON you will be able to use ROUND with non-constant values for the second argument. Internally, the query planner will translate the function call to ROUND_VAR.

For example:

txt
set enable_alternative_round to on;

select round(1.111567, seasonid), seasonid from season order by 2 limit 6;
  round   | seasonid 
----------+----------
 1.100000 |        1
 1.110000 |        2
 1.112000 |        3
 1.111600 |        4
 1.111570 |        5
 1.111567 |        6
(6 rows)

Note that when you do this, ROUND will produce the same return type that ROUND_VAR produces.