Re: BUG #10836: Rule with RETURNING claims incorrect type

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #10836: Rule with RETURNING claims incorrect type
Дата
Msg-id 1042.1404309217@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #10836: Rule with RETURNING claims incorrect type  (hoschiraffel@freenet.de)
Список 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 по дате отправления:

Предыдущее
От: Marko Tiikkaja
Дата:
Сообщение: Re: BUG #10836: Rule with RETURNING claims incorrect type
Следующее
От: Matthias Raffelsieper
Дата:
Сообщение: Re: BUG #10836: Rule with RETURNING claims incorrect type