Fwd: [TESTERS] [TEST REPORT] 9.1Alpha3 Feature E.1.4.7.2 in release notes.

From: Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Fwd: [TESTERS] [TEST REPORT] 9.1Alpha3 Feature E.1.4.7.2 in release notes.
Date: 2011-01-11 01:48:42
Message-ID: AANLkTi=dpt-nG2gax_kzWO+rjRyzk6fGsHT15JJDkFG2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-testers

It was reported from a tester that we don't have casts of money from/to integer
types even though we have from/to numeric type.

http://archives.postgresql.org/pgsql-testers/2011-01/msg00000.php

Did we have any discussions about the behavior?
I think we should have them for consistency.

---------- Forwarded message ----------
From: Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>
Date: Fri, Jan 7, 2011 at 16:34
Subject: Re: [TESTERS] [TEST REPORT] 9.1Alpha3 Feature E.1.4.7.2 in
release notes.
To: Ramanujam <innomotive(at)gmail(dot)com>
Cc: pgsql-testers(at)postgresql(dot)org

On Fri, Jan 7, 2011 at 15:54, Ramanujam <innomotive(at)gmail(dot)com> wrote:
> [Release]: 9.1Alpha3. Binaries compiled with mingw-32 (gcc 4.4.0) on
> i686 without zlib support.

> [Test]: a) Check feature E.1.4.7.2 in 9.1Alpha3 release notes
> (Monetary data type). b) Documentation mistake(?)
>
> [Results]: Documentation states that integer literals are allowed
> values for input. I am getting the following error:

The docs is:
http://developer.postgresql.org/pgdocs/postgres/datatype-money.html
| Input is accepted in a variety of formats,
| including integer and floating-point literals

The reported issue doesn't depend on lc_monetary.
It comes from missing cast support from integer to money.

Should we have cast to/from integer to numeric?  It is inconsistent
that 1::numeric::money is accepted but 1::money is not.

postgres=# SHOW lc_monetary;
 lc_monetary
-------------
 C
(1 row)

postgres=# SELECT 1::numeric::money;
 money
-------
 $1.00
(1 row)

postgres=# SELECT 1::integer::money;
ERROR:  cannot cast type integer to money
LINE 1: SELECT 1::integer::money;
                        ^
postgres=# SELECT castsource::regtype, casttarget::regtype,
castfunc::regproc, castcontext FROM pg_cast WHERE casttarget =
'money'::regtype;
 castsource | casttarget | castfunc | castcontext
------------+------------+----------+-------------
 numeric    | money      | money    | a
(1 row)

postgres=# \df money
                         List of functions
  Schema   | Name  | Result data type | Argument data types |  Type
------------+-------+------------------+---------------------+--------
 pg_catalog | money | money            | numeric             | normal
(1 row)

--
Itagaki Takahiro

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-01-11 01:56:03 Re: Bug in pg_describe_object
Previous Message Robert Haas 2011-01-11 01:46:54 Re: Bug in pg_describe_object

Browse pgsql-testers by date

  From Date Subject
Next Message Tom Lane 2011-01-11 02:10:09 Re: Fwd: [TESTERS] [TEST REPORT] 9.1Alpha3 Feature E.1.4.7.2 in release notes.
Previous Message Itagaki Takahiro 2011-01-07 07:34:33 Re: [TEST REPORT] 9.1Alpha3 Feature E.1.4.7.2 in release notes.