pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: jakubkania@onet.pl
To: pgsql-bugs@postgresql.org
Subject: BUG #7926: column 2 has type numeric(20, 2) in non-recursive term but type numeric overall
Date: Mon, 11 Mar 2013 00:06:58 +0000
Message-ID: <E1UEqGY-0000Qp-Po@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      7926
Logged by:          Jakub Kania
Email address:      jakubkania@onet.pl
PostgreSQL version: 9.1.4
Operating system:   Windows 7
Description:        

I'm not really sure what is going on but I was advised on the IRC chanell to
report it.
I get the error:
ERROR:  recursive query "bank" column 2 has type numeric(20,2) in
non-recursive term but type numeric overall
LINE 6:   SELECT ARRAY[id],amount::numeric(20,2) FROM bank_transacti...
                           ^
HINT:  Cast the output of the non-recursive term to the correct type.

********** Error **********

ERROR: recursive query "bank" column 2 has type numeric(20,2) in
non-recursive term but type numeric overall
SQL state: 42804
Hint: Cast the output of the non-recursive term to the correct type.
Character: 140



WITH RECURSIVE bank(id,amount) AS (
  SELECT ARRAY[id],amount::numeric(20,2) FROM bank_transactions
  UNION ALL
  SELECT b1.id||ARRAY[borg.id],b1.amount+borg.amount
  FROM bank AS b1 LEFT JOIN 
  bank_transactions AS borg ON borg.id>ALL(b1.id)
)
SELECT * from bank LIMIT 100;


With schema:
CREATE TABLE bank_transactions
(
  id serial NOT NULL,
  amount numeric(20,2),
  CONSTRAINT bank_transactions_pkey PRIMARY KEY (id )
)

Casting the column the error is pointing too doesn't help at all, casting
the one in the other select fixes it.
http://sqlfiddle.com/#!12/0d00c/1
http://pastebin.com/1zWYxSZZ



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



Message-ID: <E1UEqGY-0000Qp-Po@wrigleys.postgresql.org>
Permalink:  ../E1UEqGY-0000Qp-Po@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/E1UEqGY-0000Qp-Po@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: jakubkania@onet.pl
  Subject: Re: BUG #7926: column 2 has type numeric(20, 2) in non-recursive term but type numeric overall
  In-Reply-To: <E1UEqGY-0000Qp-Po@wrigleys.postgresql.org>
  References: <E1UEqGY-0000Qp-Po@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox