diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 49547ee..7aeeb9d 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -47,6 +47,16 @@ + If a memory or time setting is specified with more precision than the + implicit unit of the setting, it is rounded down. However, zero has + special meaning in some parameters, so if rounding down non-zero value + would yield a zero, it raise an error. For example, the implicit unit + of log_rotation_age is minutes, and if you set it to + 150s, it will be rounded down to two minutes. + if you set it to 10s, you will get an error. + + + Parameters of type enum are specified in the same way as string parameters, but are restricted to a limited set of values. The allowed values can be found diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index af667f5..4e39325 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -5126,10 +5126,28 @@ parse_int(const char *value, int *result, int flags, const char **hintmsg) switch (flags & GUC_UNIT_TIME) { case GUC_UNIT_S: - val /= MS_PER_S; + if (val > 0) + { + val /= MS_PER_S; + if (val == 0) + { + if (hintmsg) + *hintmsg = gettext_noop("The value is less than the required unit(second)."); + return false; + } + } break; case GUC_UNIT_MIN: - val /= MS_PER_MIN; + if (val > 0) + { + val /= MS_PER_MIN; + if (val == 0) + { + if (hintmsg) + *hintmsg = gettext_noop("The value is less than the required unit(minute)."); + return false; + } + } break; } } @@ -5142,7 +5160,16 @@ parse_int(const char *value, int *result, int flags, const char **hintmsg) val *= MS_PER_S; break; case GUC_UNIT_MIN: - val /= S_PER_MIN; + if (val > 0) + { + val /= S_PER_MIN; + if (val == 0) + { + if (hintmsg) + *hintmsg = gettext_noop("The value is less than the required unit(minute)."); + return false; + } + } break; } }