From: | Marko Tiikkaja <marko(at)joh(dot)to> |
---|---|
To: | hoschiraffel(at)freenet(dot)de, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #10836: Rule with RETURNING claims incorrect type |
Date: | 2014-07-02 13:51:23 |
Message-ID: | 53B40E5B.1050209@joh.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On 7/2/14 3:05 PM, hoschiraffel(at)freenet(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2014-07-02 13:53:37 | Re: BUG #10836: Rule with RETURNING claims incorrect type |
Previous Message | hoschiraffel | 2014-07-02 13:05:37 | BUG #10836: Rule with RETURNING claims incorrect type |