Re: Add numeric_trim(numeric)
От | Dean Rasheed |
---|---|
Тема | Re: Add numeric_trim(numeric) |
Дата | |
Msg-id | CAEZATCWTC+aHuoDw1do9kV5OLGCAfdQ=zwymwc2-x5j5axmGMw@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Add numeric_trim(numeric) (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-hackers |
On 7 January 2016 at 00:11, Tom Lane <tgl@sss.pgh.pa.us> wrote: > A different approach is that I'm not real sure why we want a function > that returns a modified numeric value at all. To the extent I understood > Marko's original use case, it seems like what you'd invariably do with the > result is extract its scale(). Why not skip the middleman and define a > function named something like minscale() or leastscale(), which returns an > int that is the smallest scale that would not drop data? (If you actually > did want the modified numeric value, you could use round(x, minscale(x)) > to get it.) > minscale() sounds good to me. Re-reading Marko's original use case, it sounds like that specific example would boil down to a check that minscale(x) <= 2, although that can be done today using trunc(x,2) = x. Still, it seems that minscale() would be a useful general purpose function to have. Regards, Dean
В списке pgsql-hackers по дате отправления: