Re: [PATCH v1 0/2] Preserve input sign across numeric parameter parsing

From: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
To: Haibo Yan <tristan(dot)yim(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Subject: Re: [PATCH v1 0/2] Preserve input sign across numeric parameter parsing
Date: 2026-11-20 11:56:57
Message-ID: CABPTF7V9bgKZQWehB_n0snXw0uE8TdsJ8+ehsjVjXEY0v1NbiA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"This series deliberately does not change the existing behavior for positive GUC
values that round to zero. For example, statement_timeout = ‘0.4ms’ still
becomes 0. It also does not address the separate parse_real() unit-conversion
precision issue."

I am curious why you chose to preserve the existing behavior for
positive GUC values to zero?
Another more concerning drawback for this conversion is that it does
not respect the original value.

it could give wrong values for these:

statement_timeout = '0.144min' -> 9s (8.64 s)
statement_timeout = '0.021d' -> 1h (30.24 min)

I think this results from 1a83a80a2fe (PG12), convert_to_base_unit()
rounds a fractional value to the next smaller unit than the input one.
It was added for the sake of showing memory settings nicely, but
without taking time value into proper consideration [2].

cvalue = rint(cvalue / table[i + 1].multiplier) *
table[i + 1].multiplier;

Converting time exactly without next-unit rounding seems able to cover
both the truncation and zeroing well. I understand that this is a
broader behavior change. But it seems worthwhile to trade a bit of
readability for accuracy.

'0.144min' -> 8640ms
'0.020d' -> 1728s
'0.021d' -> 1814400ms
'-0.4ms', '0.4ms' -> rejected by rule 2

Does this seem sensible to you?

[1] https://postgr.es/m/20054.1552251519@sss.pgh.pa.us
[2] https://postgr.es/m/20190312.124559.221664593.horiguchi.kyotaro@lab.ntt.co.jp

--
Regards,
Xuneng Zhou
HighGo Software Co., Ltd.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2026-11-20 12:00:37 Re: [PATCH]Fix planner's strictness check for JsonExpr
Previous Message Fujii Masao 2026-11-20 11:49:27 Re: Fix resource leaks in pg_receivewal on LZ4 close failures