Re: proposal: minscale, rtrim, btrim functions for numeric

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: "Karl O(dot) Pinc" <kop(at)meme(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Marko Tiikkaja <marko(at)joh(dot)to>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: proposal: minscale, rtrim, btrim functions for numeric
Date: 2020-01-06 17:22:50
Message-ID: 28099.1578331370@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
> út 10. 12. 2019 v 13:56 odesílatel Karl O. Pinc <kop(at)meme(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2020-01-06 17:25:19 Re: Assert failure due to "drop schema pg_temp_3 cascade" for temporary tables and \d+ is not showing any info after drooping temp table schema
Previous Message Robert Haas 2020-01-06 16:29:02 Re: Removing pg_pltemplate and creating "trustable" extensions