Thread: Non-standard function names

Non-standard function names

From
Clive Page
Date:
The developers of Postgres over the years are to be commended on their
support for SQL Standards, but one thing that has annoyed me for some time
is that the names of several mathematical functions are seriously
non-standard.  Postgres isn't actually flouting an SQL Standard in this
area as there isn't one as far as I can discover, but the JDBC
specification includes a number of function names, and most other DBMS use
the same ones, more-or-less.  I put together a small web page comparing
the function names in use in various products:
http://wiki.astrogrid.org/bin/view/Astrogrid/DBMSmathFunctions

Here one can see that Postgres actually has 6 deviations from the de-facto
JDBC standard, more than any other DBMS I examined, while MySQL comes out
as the most conformant, surprisingly.

Four of these could be fixed easily, by allowing CEILING to be a synonym
for CEIL, and similarly POW for POWER, RAND for RANDOM, and TRUNCATE for
TRUNC.  Does anyone see any problems with doing that?  It would surely
help people porting applications over from other DBMS.

The problems come with LN and LOG which Postgres uses for logarithms to
base e and 10 respectively: the JDBC standard uses LOG and LOG10
respectively, so that any fix would mean LOG changed its meaning.  I don't
see an easy solution here; maybe both LOGE and LOG10 could be provided, at
least there would then be only one difference from the JDBC standard.



-- 
Clive Page
Dept of Physics & Astronomy,
University of Leicester,
Leicester, LE1 7RH,  U.K.



Re: Non-standard function names

From
Tom Lane
Date:
Clive Page <cgp@star.le.ac.uk> writes:
> The problems come with LN and LOG which Postgres uses for logarithms to
> base e and 10 respectively: the JDBC standard uses LOG and LOG10
> respectively, so that any fix would mean LOG changed its meaning.  I don't
> see an easy solution here; maybe both LOGE and LOG10 could be provided, at
> least there would then be only one difference from the JDBC standard.

loge() strikes me as pointless; you might as well just use ln().
I don't have any objections to the other proposed additions though.
        regards, tom lane