From: Tom Lane <tgl@sss.pgh.pa.us>
To: hoschiraffel@freenet.de
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #10836: Rule with RETURNING claims incorrect type
Date: Wed, 02 Jul 2014 09:53:37 -0400
Message-ID: <1042.1404309217@sss.pgh.pa.us> (raw)
In-Reply-To: <20140702130537.5170.32873@wrigleys.postgresql.org>
References: <20140702130537.5170.32873@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, hoschiraffel@freenet.de
Subject: Re: BUG #10836: Rule with RETURNING claims incorrect type
In-Reply-To: <1042.1404309217@sss.pgh.pa.us>
References: <20140702130537.5170.32873@wrigleys.postgresql.org> <1042.1404309217@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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