Re: proposal: minscale, rtrim, btrim functions for numeric
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: "Karl O. Pinc" <kop@meme.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Marko Tiikkaja <marko@joh.to>,
Dean Rasheed <dean.a.rasheed@gmail.com>,
Alvaro Herrera <alvherre@2ndquadrant.com>,
Robert Haas <robertmhaas@gmail.com>
Date: 2020-01-06T17:22:50Z
Lists: pgsql-hackers
Pavel Stehule <pavel.stehule@gmail.com> writes: > út 10. 12. 2019 v 13:56 odesílatel Karl O. Pinc <kop@meme.com> napsal: >> I'm marking it ready for a committer. > Thank you for review Pushed with minor adjustments. Notably, I didn't like having get_min_scale() depend on its callers having stripped trailing zeroes to avoid getting into a tight infinite loop. That's just trouble waiting to happen, especially since non-stripped numerics are seldom seen in practice (ones coming into the SQL-level functions should never look like that, ie the strip_var calls you had are almost certainly dead code). If we did have a code path where the situation could occur, and somebody forgot the strip_var call, the omission could easily escape notice. So I got rid of the strip_var calls and made get_min_scale() defend itself against the case. It's hardly any more code, and it should be a shade faster than strip_var anyway. regards, tom lane
Commits
-
Add functions min_scale(numeric) and trim_scale(numeric).
- 20d6225d1656 13.0 landed