From: Marko Tiikkaja <marko@joh.to>
To: hoschiraffel@freenet.de
To: pgsql-bugs@postgresql.org
Subject: Re: BUG #10836: Rule with RETURNING claims incorrect type
Date: Wed, 02 Jul 2014 15:51:23 +0200
Message-ID: <53B40E5B.1050209@joh.to> (raw)
In-Reply-To: <20140702130537.5170.32873@wrigleys.postgresql.org>
References: <20140702130537.5170.32873@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On 7/2/14 3:05 PM, hoschiraffel@freenet.de wrote:
> In essence, I observe that when explicitly listing columns in a RETURNING
> statement of a rule, the type checking is somehow thrown off. When using the
> '*' all is fine. Please see below for a small example session that exhibits
> this bug.
>
> $ psql test
> psql (9.3.4)
> Type "help" for help.
>
> test=# \set VERBOSITY verbose
> test=# create table foobar (id int, info text);
> CREATE TABLE
> test=# create view test_me as select id as foo, info as bar from foobar;
> CREATE VIEW
> test=# create rule test_me_ins as on insert to test_me do instead insert
> into foobar values (new.foo,new.bar) returning (id,info);
> ERROR: 42P17: RETURNING list's entry 1 has different type from column
> "foo"
> LOCATION: checkRuleResultList, rewriteDefine.c:682
You're actually only returning a single column. RETURNING (id, info)
is the same as RETURNING ROW(id, info), which is very different from
RETURNING id, info. See
http://www.postgresql.org/docs/9.3/static/rowtypes.html, for example.
Note that this behaviour is the same as in SELECT lists; SELECT (id,
info) FROM foobar; will also only give you a single column.
.marko
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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: marko@joh.to, hoschiraffel@freenet.de
Subject: Re: BUG #10836: Rule with RETURNING claims incorrect type
In-Reply-To: <53B40E5B.1050209@joh.to>
References: <20140702130537.5170.32873@wrigleys.postgresql.org> <53B40E5B.1050209@joh.to>
* 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