bug in the money type - Mailing list pgsql-bugs

From Geoff Reedy
Subject bug in the money type
Date
Msg-id 20010717164553.A17380@imsa.edu
Whole thread Raw
Responses Re: bug in the money type
List pgsql-bugs
============================================================================
                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================


Your name        :    Geoffrey Reedy
Your email address    :    vader21@imsa.edu


System Configuration
---------------------
  Architecture (example: Intel Pentium)      :   Intel Pentium III

  Operating System (example: Linux 2.0.26 ELF)     :   Linux 2.2.14 ELF SMP

  PostgreSQL version (example: PostgreSQL-7.1.1):   PostgreSQL-7.1.2

  Compiler used (example:  gcc 2.95.2)        :   unknown (binary RPM)


Please enter a FULL description of your problem:
------------------------------------------------

The money type fails at the roll-over value of 21474836.48 (2^31). On either
side of 21474836.48 (2^31) the money evaluates to the expected result
(+- 21474836.47).  Calling some functions with this problematic monetary
value causes the backend to exit unexpectedly.

Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

vader21=> select (money '21474836.47');
    ?column?
----------------
 $21,474,836.47
(1 row)

vader21=> select (money '21474836.49');
    ?column?
-----------------
 -$21,474,836.47
(1 row)

vader21=> select (money '21474836.48');
    ?column?
-----------------
 -$./,,),,(-*.,(
(1 row)

vader21=> select cash_words(money '21474836.48');
pqReadData() -- backend closed the channel unexpectedly.
    This probably means the backend terminated abnormally
    before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.

If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

Probably just a bounds check in src/backend/utils/adt/cash.c needs to be
added.  I could probably whip up a patch, but don't have time to do that
right now.  Perhaps in the next few days I will be able to do that.

--
Geoffrey Reedy                                       vader21@imsa.edu

pgsql-bugs by date:

Previous
From: Eugene Fokin
Date:
Subject: Re: libpgtcl doesn't use UTF encoding of TCL
Next
From: Jefim Matskin
Date:
Subject: create view bug