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

From: "Karl O(dot) Pinc" <kop(at)meme(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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: 2019-12-09 02:22:39
Message-ID: 20191208202239.2a9908f3@slate.karlpinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, 08 Dec 2019 13:57:00 -0500
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> "Karl O. Pinc" <kop(at)meme(dot)com> writes:
> > FWIW, I bumped around the Internet and looked at Oracle docs to see
> > if there's any reason why minscale() might not be a good function
> > name. I couldn't find any problems.
>
> > I also couldn't think of a better name than trim_scale() and don't
> > have any problems with the name.
>
> I'd just comment that it seems weird that the same patch is
> introducing two functions with inconsistently chosen names. Why does
> one have an underscore separating the words and the other not? I
> haven't got a large investment in either naming convention
> specifically, but it'd be nice if we could at least pretend to be
> considering consistency.

Consistency would be lovely. I don't feel qualified
to make the decision but here's what I came up with:

I re-read the back-threads and don't see any discussion
of the naming of minscale().

My thoughts run toward asking
the "what is a word?" question, along with "what is the
policy for separating a word?". Is "min" different
from the prefix "sub"?

"Trim" seems to clearly count as a word and trim_scale()
seems mostly consistent with existing function names.
(E.g. width_bucket(), convert_to(). But there's no
true consistency. Plenty of functions don't separate
words with "_". E.g. setseed().)

As far as "min" goes, glancing through function names [1]
does not help much. The index indicates that when PG puts "min"
in a configuration parameter it separates it with "_".
(Looking at "min" in the index.)
Looking at the function names containing "min" [2] yields:

aclitemin
brin_minmax_add_value
brin_minmax_consistent
brin_minmax_opcinfo
brin_minmax_union
min
numeric_uminus
pg_terminate_backend
range_minus
txid_snapshot_xmin

Not especially helpful.

I'm inclined to want
min_scale() instead of "minscale()" based on
how config parameters are named and for consistency
with trim_scale(). Pavel, if you agree then
let's just change minscale() to min_scale() and
let people object if they don't like it.

Regards.

Karl <kop(at)meme(dot)com>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein

[1]
select pg_proc.proname
from pg_proc
group by pg_proc.proname
order by pg_proc.proname;

[2]
select pg_proc.proname
from pg_proc
where pg_proc.proname like '%min%'
group by pg_proc.proname
order by pg_proc.proname;

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Karl O. Pinc 2019-12-09 02:51:18 Re: proposal: minscale, rtrim, btrim functions for numeric
Previous Message Craig Ringer 2019-12-09 02:22:12 Re: ssl passphrase callback