Thread: ceiling() and power() (SQL2003)

ceiling() and power() (SQL2003)

From
Neil Conway
Date:
This patch makes the following changes:

(1) Add ceiling() as an alias for ceil() (both double precision and
numeric variants). This is required by SQL2003, so both spellings of
the function name have been documented.

(2) Add power() as an alias for pow(). SQL2003 only defines power()
AFAICS. Rather than documenting two identical spellings of the same
command, I think it makes sense to migrate toward the spelling that is
preferred by the standard. Therefore, I renamed the documentation for
pow() to refer to power().

I didn't remove pow(): that would break far too much existing code, and
there is little harm in keeping around an additional pg_proc entry or
two. I think that keeping pow() but not documenting it should ensure
that new users prefer power() but older applications do not need to be
changed, which is a reasonable compromise between backward
compatibility and forward progress.

Regression tests are included (I believe I updated all the variants of
float8 properly, but please speak up if that is not the case). This
patch bumps the catalog version number.

Barring any objections, I intend to apply this within 24 hours.

-Neil

Attachment

Re: ceiling() and power() (SQL2003)

From
Neil Conway
Date:
On 1-May-04, at 2:04 AM, Hans-Jürgen Schönig wrote:
> Doesn't your patch cause problems with the PostgreSQL ODBC driver
> which adds [...]

I don't think this will cause an error (I tried it locally, and pg_proc
rows for the new functions are installed, but power() and ceiling()
continue to work). Of course, now that PostgreSQL includes these
functions the ODBC driver doesn't need to define them itself (and it
should not do so).

-Neil


Re: ceiling() and power() (SQL2003)

From
Hans-Jürgen Schönig
Date:
Neil,

Doesn't your patch cause problems with the PostgreSQL ODBC driver which
adds ...


-- CEILING(num)
CREATE OR REPLACE FUNCTION ceiling(numeric) RETURNS numeric AS '
     SELECT ceil($1);
' LANGUAGE SQL;


-- POWER(num, num)
CREATE OR REPLACE FUNCTION power(double precision, double precision)
   RETURNS double precision AS '
     SELECT pow($1, $2);
' LANGUAGE SQL;
CREATE OR REPLACE FUNCTION power(numeric, numeric)
   RETURNS numeric AS '
     SELECT pow($1, $2);
' LANGUAGE SQL;


On first glance this seems to be same ...

    Regards,

        Hans



Neil Conway wrote:
> This patch makes the following changes:
>
> (1) Add ceiling() as an alias for ceil() (both double precision and
> numeric variants). This is required by SQL2003, so both spellings of the
> function name have been documented.
>
> (2) Add power() as an alias for pow(). SQL2003 only defines power()
> AFAICS. Rather than documenting two identical spellings of the same
> command, I think it makes sense to migrate toward the spelling that is
> preferred by the standard. Therefore, I renamed the documentation for
> pow() to refer to power().
>
> I didn't remove pow(): that would break far too much existing code, and
> there is little harm in keeping around an additional pg_proc entry or
> two. I think that keeping pow() but not documenting it should ensure
> that new users prefer power() but older applications do not need to be
> changed, which is a reasonable compromise between backward compatibility
> and forward progress.
>
> Regression tests are included (I believe I updated all the variants of
> float8 properly, but please speak up if that is not the case). This
> patch bumps the catalog version number.
>
> Barring any objections, I intend to apply this within 24 hours.
>
> -Neil
>
>
> ------------------------------------------------------------------------
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org


--
Cybertec Geschwinde u Schoenig
Schoengrabern 134, A-2020 Hollabrunn, Austria
Tel: +43/2952/30706 or +43/664/233 90 75
www.cybertec.at, www.postgresql.at, kernel.cybertec.at


Re: ceiling() and power() (SQL2003)

From
Christopher Kings-Lynne
Date:
> Doesn't your patch cause problems with the PostgreSQL ODBC driver which
> adds ...

Well, the odbc driver will be able to drop those functions.  Also,
Neil's functions will appear in pg_catalog while the odbc ones will be
in public, so there won't be a conflict as such.

Chris