X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EA553D6857 for ; Tue, 22 Nov 2005 15:42:18 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03569-06 for ; Tue, 22 Nov 2005 19:42:18 +0000 (GMT) X-Greylist: delayed 19:04:42.962034 by SQLgrey- Received: from pow.actarg.com (host25.actarg.com [209.180.91.25]) by svr1.postgresql.org (Postfix) with ESMTP id B3D16DB0DE for ; Tue, 22 Nov 2005 15:42:15 -0400 (AST) Received: from [192.168.2.50] (nb0.actarg.com [192.168.2.50]) (authenticated bits=0) by pow.actarg.com (8.13.1/8.13.1) with ESMTP id jAMJg3QR023909 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Nov 2005 12:42:10 -0700 Message-ID: <43837E9B.20306@actarg.com> Date: Tue, 22 Nov 2005 13:24:59 -0700 From: Kyle Bateman User-Agent: Mozilla Thunderbird 0.9 (X11/20041127) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane CC: pgsql-sql@postgresql.org Subject: Re: unplanned sub-select error? References: <43826850.1020302@actarg.com> <6603.1132621854@sss.pgh.pa.us> In-Reply-To: <6603.1132621854@sss.pgh.pa.us> Content-Type: multipart/mixed; boundary="------------080905080702010704050505" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.09 required=5 tests=[AWL=0.090] X-Spam-Score: 0.09 X-Spam-Level: X-Archive-Number: 200511/210 X-Sequence-Number: 23461 This is a multi-part message in MIME format. --------------080905080702010704050505 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Tom Lane wrote: >Kyle Bateman writes: > > >>I have a query: >>insert into mtr_reg_v_wt (ropnum, inum, pnum, rquant, value, status, >>ddate, fr_proj, to_proj) values (28985,1,1014,1,(select cost from >>prd_part where pnum = 1014),'work','2005-Nov-15',50,75); >> >> > > > >>That used to work fine under 7.1.3 but now gives the error: >> >> > > > >>ERROR: cannot handle unplanned sub-select >> >> > >You need to offer a little more context, like what PG version you are >using now and what is the underlying DDL --- I suspect some rules or >views are involved here, but you didn't show them to us. > > > Sorry, you're right. I have now confirmed that this only happens when updating via a view/rule (as you suspected). Attached is a minimalist sql file that demonstrates the same error message from a blank database. I'm using 8.1.0. I'm pretty sure this problem did not exist on 8.0.3. Kyle --------------080905080702010704050505 Content-Type: text/x-sql; name="testmtr.sql" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="testmtr.sql" -- Expose the "unplanned sub-select" error message create table parts ( partnum varchar(18) primary key, cost float8 ); create table shipped ( ttype char(2), ordnum int4, partnum varchar(18) references parts, value float8, primary key (ttype, ordnum) ); create view shipped_view as select * from shipped where ttype = 'wt'; create rule shipped_view_insert as on insert to shipped_view do instead insert into shipped (ttype, ordnum, partnum, value) values ('wt', new.ordnum, new.partnum, new.value); insert into parts (partnum, cost) values (1, 1234.56); insert into shipped_view (ordnum, partnum, value) values (100,1,(select cost from parts where partnum = 1)); --------------080905080702010704050505--