Re: BUG #10836: Rule with RETURNING claims incorrect type - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #10836: Rule with RETURNING claims incorrect type
Date
Msg-id 1042.1404309217@sss.pgh.pa.us
Whole thread Raw
In response to BUG #10836: Rule with RETURNING claims incorrect type  (hoschiraffel@freenet.de)
List 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

pgsql-bugs by date:

Previous
From: Marko Tiikkaja
Date:
Subject: Re: BUG #10836: Rule with RETURNING claims incorrect type
Next
From: Matthias Raffelsieper
Date:
Subject: Re: BUG #10836: Rule with RETURNING claims incorrect type