Re: numeric precision when raising one numeric to - Mailing list pgsql-general

From Bruce Momjian
Subject Re: numeric precision when raising one numeric to
Date
Msg-id 200505302058.j4UKwhV16426@candle.pha.pa.us
Whole thread Raw
In response to Re: numeric precision when raising one numeric to  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Tom Lane wrote:
> Has anyone bothered to actually look into the code?
>
> regression=# select power(2::numeric,1000);
>                                                                               power
>
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376.0000000000000000
> (1 row)
>
> AFAICT the only thing missing is a pg_operator entry linked to the
> function.

Patch to add NUMERIC ^ NUMERIC operator added and applied.  Catalog
version bumped.  This will be in 8.1.  FYI, this already does the right
thing (no rounding) if the second argument is an integal value, see
power_var().

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/include/catalog/catversion.h
===================================================================
RCS file: /cvsroot/pgsql/src/include/catalog/catversion.h,v
retrieving revision 1.271
diff -c -c -r1.271 catversion.h
*** src/include/catalog/catversion.h    30 May 2005 06:52:38 -0000    1.271
--- src/include/catalog/catversion.h    30 May 2005 20:54:25 -0000
***************
*** 53,58 ****
   */

  /*                            yyyymmddN */
! #define CATALOG_VERSION_NO    200505301

  #endif
--- 53,58 ----
   */

  /*                            yyyymmddN */
! #define CATALOG_VERSION_NO    200505302

  #endif
Index: src/include/catalog/pg_operator.h
===================================================================
RCS file: /cvsroot/pgsql/src/include/catalog/pg_operator.h,v
retrieving revision 1.131
diff -c -c -r1.131 pg_operator.h
*** src/include/catalog/pg_operator.h    14 Apr 2005 01:38:20 -0000    1.131
--- src/include/catalog/pg_operator.h    30 May 2005 20:54:26 -0000
***************
*** 695,700 ****
--- 695,701 ----
  DATA(insert OID = 1760 (  "*"       PGNSP PGUID b f 1700 1700 1700 1760    0 0 0 0 0 numeric_mul - - ));
  DATA(insert OID = 1761 (  "/"       PGNSP PGUID b f 1700 1700 1700     0    0 0 0 0 0 numeric_div - - ));
  DATA(insert OID = 1762 (  "%"       PGNSP PGUID b f 1700 1700 1700     0    0 0 0 0 0 numeric_mod - - ));
+ DATA(insert OID = 1038 (  "^"       PGNSP PGUID b f 1700 1700 1700     0    0 0 0 0 0 numeric_power - - ));
  DATA(insert OID = 1763 (  "@"       PGNSP PGUID l f    0 1700 1700    0    0 0 0 0 0 numeric_abs - - ));

  DATA(insert OID = 1784 (  "="      PGNSP PGUID b f 1560 1560 16 1784 1785 1786 1786 1786 1787 biteq eqsel eqjoinsel
));

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: CREATE TEMP TABLE AS SELECT/ GET DIAGNOSTICS ROW_COUNT
Next
From: Tom Lane
Date:
Subject: Re: CREATE TEMP TABLE AS SELECT/ GET DIAGNOSTICS ROW_COUNT