Re: [PATCHES] ':' and ';' operators - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: [PATCHES] ':' and ';' operators
Date
Msg-id Pine.GSO.4.02A.9911251323160.16412-100000@Panter.DoCS.UU.SE
Whole thread Raw
Responses Re: [HACKERS] Re: [PATCHES] ':' and ';' operators
Re: [HACKERS] Re: [PATCHES] ':' and ';' operators
initdb messed up
List pgsql-hackers
On Wed, 24 Nov 1999, Tom Lane wrote:

> Peter Eisentraut <peter_e@gmx.net> writes:
> > This patch removes the ';' (logarithm) and ':' (exponentiation) operators,
> > as was generally agreed upon.
> 
> This is a tad premature IMHO.  In the first place, we haven't got the
> replacement functions --- at least not with user-friendly names.
> In the second place, I think we oughta deprecate these things for a
> release or two before we actually remove 'em.

Deprecation is not going to work in this case because those two operators
interfere with their blessed SQL meaning. And now is the time to remove
them. The reason I wanted them removed now is that it is a pain to account
for them, or even disambiguate them, in psql. I guess for now I will no
longer bother with them.

At the risk of taking on more work and/or provoking a holy war, I think
the mathematical operators and function names need some cleaning up in
general. From the previous conversation on this topic I gathered that a
lot of these things are from PostQUEL times. Also, there is some confusion
between float and numeric operators and functions and sometimes they only
work on one, etc.

I don't have the SQL standards around here, but they should be the
reference, so if someone could fill me in. Barring anything that's in
there, I think that there should be a standard set of functions, such as
this:
exp()
log()
pow()
sin(), cos(), ...
abs()
sgn()
factorial()
sqrt()
surd()
floor()
ceil()
trunc()
round()
as well as anything else that's easily thrown in because it's already in
math.h.

All of these functions should be overloaded for float4, float8, and
numeric, as well as int* where appropriate. Some might argue that things
such as sin() or exp() do not make sense for numeric and you should cast
it to float. I'm not sure myself.

Operators should only be assigned if they are in the standard and/or they
make sense to a math person. To me (being a math person), this would
particularly disqualify these operators:
!! -- factorial left operator
%  -- truncation left operator (as opposed to % modulo)
:  -- exponentiation
;  -- logarithm
@  -- absolute value

(Tom speculated that someone might have had some fun writing the parser
and hence threw in these things.)

Rationale:
* Compatibility: break it now or be stuck with it forever
* If anyone actually used the above operators in those meanings, I will
personally congratulate them.
* Someone will have to do it eventually.

This is not something I could do tomorrow anyway, so we can have an
extended discussion. I'm looking forward to it ...

> BTW: a patch that removes user-visible features and breaks regress
> tests is incomplete without doc and test updates...

When will I ever learn ...
Sorry.

-- 
Peter Eisentraut                  Sernanders vaeg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden



pgsql-hackers by date:

Previous
From: wieck@debis.com (Jan Wieck)
Date:
Subject: Re: [HACKERS] lztext and parser
Next
From: Tim Holloway
Date:
Subject: Re: [HACKERS] pid file for postmaster?