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