pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #10836: Rule with RETURNING claims incorrect type
6+ messages / 4 participants
[nested] [flat]
* BUG #10836: Rule with RETURNING claims incorrect type
@ 2014-07-02 13:05 hoschiraffel@freenet.de
2014-07-02 13:51 ` Re: BUG #10836: Rule with RETURNING claims incorrect type Marko Tiikkaja <marko@joh.to>
2014-07-02 13:53 ` Re: BUG #10836: Rule with RETURNING claims incorrect type Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 6+ messages in thread
From: hoschiraffel@freenet.de @ 2014-07-02 13:05 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 10836
Logged by: Matthias Raffelsieper
Email address: hoschiraffel@freenet.de
PostgreSQL version: 9.3.4
Operating system: Mac OSX
Description:
Hi all.
While trying to create rules, I hit a situation that I figure might be a
bug.
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
test=# create rule test_me_ins as on insert to test_me do instead insert
into foobar values (new.foo,new.bar) returning *;
CREATE RULE
test=# insert into test_me VALUES (1,'hello');
INSERT 0 1
test=# insert into test_me VALUES (2,'world') returning bar;
bar
-------
world
(1 row)
INSERT 0 1
test=# select * from test_me;
foo | bar
-----+-------
1 | hello
2 | world
(2 rows)
test=#
Cheers,
Matt
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #10836: Rule with RETURNING claims incorrect type
2014-07-02 13:05 BUG #10836: Rule with RETURNING claims incorrect type hoschiraffel@freenet.de
@ 2014-07-02 13:51 ` Marko Tiikkaja <marko@joh.to>
2014-07-02 14:06 ` Re: BUG #10836: Rule with RETURNING claims incorrect type Matthias Raffelsieper <hoschiraffel@freenet.de>
1 sibling, 1 reply; 6+ messages in thread
From: Marko Tiikkaja @ 2014-07-02 13:51 UTC (permalink / raw)
To: hoschiraffel@freenet.de; pgsql-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
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #10836: Rule with RETURNING claims incorrect type
2014-07-02 13:05 BUG #10836: Rule with RETURNING claims incorrect type hoschiraffel@freenet.de
2014-07-02 13:51 ` Re: BUG #10836: Rule with RETURNING claims incorrect type Marko Tiikkaja <marko@joh.to>
@ 2014-07-02 14:06 ` Matthias Raffelsieper <hoschiraffel@freenet.de>
2014-07-02 16:45 ` Re: BUG #10836: Rule with RETURNING claims incorrect type Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 6+ messages in thread
From: Matthias Raffelsieper @ 2014-07-02 14:06 UTC (permalink / raw)
To: pgsql-bugs
On 7/2/14 3:51 PM, Marko Tiikkaja wrote:
> On 7/2/14 3:05 PM, hoschiraffel@freenet.de wrote:
>> [...]
>
> 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.
Hello Marko.
Thanks for the explanation and sorry for not spotting my mistake. Please
close this bug as invalid.
It would however have helped if I had gotten back the expected type and
the actually provided type; even in verbose mode this was not supplied.
Would this be possible, or is there already a configuration option to
enable this?
Cheers,
Matt
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #10836: Rule with RETURNING claims incorrect type
2014-07-02 13:05 BUG #10836: Rule with RETURNING claims incorrect type hoschiraffel@freenet.de
2014-07-02 13:51 ` Re: BUG #10836: Rule with RETURNING claims incorrect type Marko Tiikkaja <marko@joh.to>
2014-07-02 14:06 ` Re: BUG #10836: Rule with RETURNING claims incorrect type Matthias Raffelsieper <hoschiraffel@freenet.de>
@ 2014-07-02 16:45 ` Tom Lane <tgl@sss.pgh.pa.us>
2014-07-03 09:12 ` Re: BUG #10836: Rule with RETURNING claims incorrect type Matthias Raffelsieper <hoschiraffel@freenet.de>
0 siblings, 1 reply; 6+ messages in thread
From: Tom Lane @ 2014-07-02 16:45 UTC (permalink / raw)
To: Matthias Raffelsieper <hoschiraffel@freenet.de>; +Cc: pgsql-bugs
Matthias Raffelsieper <hoschiraffel@freenet.de> writes:
> It would however have helped if I had gotten back the expected type and
> the actually provided type; even in verbose mode this was not supplied.
Yeah, I came to the same conclusion. I've done something about this:
http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=7980ab30ecf36162699f138697e2ff5589...
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #10836: Rule with RETURNING claims incorrect type
2014-07-02 13:05 BUG #10836: Rule with RETURNING claims incorrect type hoschiraffel@freenet.de
2014-07-02 13:51 ` Re: BUG #10836: Rule with RETURNING claims incorrect type Marko Tiikkaja <marko@joh.to>
2014-07-02 14:06 ` Re: BUG #10836: Rule with RETURNING claims incorrect type Matthias Raffelsieper <hoschiraffel@freenet.de>
2014-07-02 16:45 ` Re: BUG #10836: Rule with RETURNING claims incorrect type Tom Lane <tgl@sss.pgh.pa.us>
@ 2014-07-03 09:12 ` Matthias Raffelsieper <hoschiraffel@freenet.de>
0 siblings, 0 replies; 6+ messages in thread
From: Matthias Raffelsieper @ 2014-07-03 09:12 UTC (permalink / raw)
To: pgsql-bugs
On 07/02/2014 18:45, Tom Lane wrote:
> Matthias Raffelsieper <hoschiraffel@freenet.de> writes:
>> It would however have helped if I had gotten back the expected type and
>> the actually provided type; even in verbose mode this was not supplied.
>
> Yeah, I came to the same conclusion. I've done something about this:
> http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=7980ab30ecf36162699f138697e2ff5589...
>
Wow, that was fast, thanks a lot. I just had the time to check it out
and I believe that this also helps in other cases where one might mix up
the RETURNING columns.
Thanks again,
Matt
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #10836: Rule with RETURNING claims incorrect type
2014-07-02 13:05 BUG #10836: Rule with RETURNING claims incorrect type hoschiraffel@freenet.de
@ 2014-07-02 13:53 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 6+ messages in thread
From: Tom Lane @ 2014-07-02 13:53 UTC (permalink / raw)
To: hoschiraffel@freenet.de; +Cc: pgsql-bugs
hoschiraffel@freenet.de writes:
> 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"
This is a syntax mistake. What you wrote is equivalent to
returning row(id,info);
so it returns a single composite column rather than the required int and
text columns, so the complaint is correct (if unhelpful :-().
Leave off the parens:
returning id,info;
I'm not sure if there's anything much we could do about improving the
situation. Allowing a row constructor with just parens is required by
SQL standard, but I've seen people confused before by thinking that
outer parens are just syntactic decoration that don't change the meaning
of the expression. Maybe if we just mentioned the two types (record vs
int, in this case) the user's mind would be led in the right direction?
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2014-07-03 09:12 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-07-02 13:05 BUG #10836: Rule with RETURNING claims incorrect type hoschiraffel@freenet.de
2014-07-02 13:51 ` Marko Tiikkaja <marko@joh.to>
2014-07-02 14:06 ` Matthias Raffelsieper <hoschiraffel@freenet.de>
2014-07-02 16:45 ` Tom Lane <tgl@sss.pgh.pa.us>
2014-07-03 09:12 ` Matthias Raffelsieper <hoschiraffel@freenet.de>
2014-07-02 13:53 ` Tom Lane <tgl@sss.pgh.pa.us>
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