Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X2Kwg-0000uZ-D9 for pgsql-bugs@arkaria.postgresql.org; Wed, 02 Jul 2014 13:51:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1X2Kwf-0002My-Ra for pgsql-bugs@arkaria.postgresql.org; Wed, 02 Jul 2014 13:51:33 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1X2Kwe-0002KE-Na for pgsql-bugs@postgresql.org; Wed, 02 Jul 2014 13:51:32 +0000 Received: from mail-we0-f173.google.com ([74.125.82.173]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1X2KwZ-0004xP-R2 for pgsql-bugs@postgresql.org; Wed, 02 Jul 2014 13:51:30 +0000 Received: by mail-we0-f173.google.com with SMTP id t60so11264962wes.32 for ; Wed, 02 Jul 2014 06:51:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=WlcOZs0IXJsO/c8NOKE9/bD+mQ4CNeBbcBs8G0NKHxc=; b=XIcDAPKXQ4QSbn/7Dtboq2fbQ6vihF4UDOKmgmkqC1jCDK+J/FnwLsPL+jXNGG1IsA b6b3C4OJXZRzpG3A6upkYwjHQ4dLfdZBSI2ltSCvtm5VK8bHHEpuTVdiBTlrflHopI7D hpcRi+C4n/5XYIoeFVcCZNGbCouXJGiQCfDEMqb98bAdana6xB4C1nIwVDP1duyYg5K5 +vZT/Ct5CKeGDinI6tPZV7XYc9qCEUGcPEDG/wgbNjG/DloyFvOIXxPRISJA01OBNCQy EMfr97xlFnyLbUUCdxfboYYqoK2Bbi9TobJJ6N/Ci43h9tT1xBlsbBv9ueNzHKGRhHgl xfsw== X-Gm-Message-State: ALoCoQlb/3m/94M+aFPs0D4d4cN/8t+HlXtLUlBMcdreP4oK2W7EEmFKcMLAOVWESG5IOje5AkcM X-Received: by 10.194.2.244 with SMTP id 20mr57515185wjx.26.1404309084650; Wed, 02 Jul 2014 06:51:24 -0700 (PDT) Received: from Markos-MacBook-Pro.local ([46.246.117.202]) by mx.google.com with ESMTPSA id ev9sm55434594wic.24.2014.07.02.06.51.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Jul 2014 06:51:24 -0700 (PDT) Message-ID: <53B40E5B.1050209@joh.to> Date: Wed, 02 Jul 2014 15:51:23 +0200 From: Marko Tiikkaja User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: hoschiraffel@freenet.de, pgsql-bugs@postgresql.org Subject: Re: BUG #10836: Rule with RETURNING claims incorrect type References: <20140702130537.5170.32873@wrigleys.postgresql.org> In-Reply-To: <20140702130537.5170.32873@wrigleys.postgresql.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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