X-Original-To: pgsql-hackers-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id A5AF69FA502 for ; Thu, 20 Jul 2006 02:39:49 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 38209-02 for ; Thu, 20 Jul 2006 02:39:38 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 09D749FA5CD for ; Thu, 20 Jul 2006 02:39:37 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k6K5dV20023928; Thu, 20 Jul 2006 01:39:31 -0400 (EDT) To: Joe Conway cc: Christopher Kings-Lynne , "Hackers (PostgreSQL)" , Andrew Dunstan , Bernd Helmle , Peter Eisentraut , Susanne Ebrecht Subject: Re: [PATCHES] 8.2 features? In-reply-to: <44BF122F.1080200@joeconway.com> References: <44B69778.5050104@dunslane.net> <50461.84.63.113.55.1152832991.squirrel@pezone.net> <44B7ADFC.90205@dunslane.net> <44BC0432.3040509@joeconway.com> <44BC661F.80609@joeconway.com> <44BCD06C.3060409@calorieking.com> <44BCF1D4.3010807@dunslane.net> <5842.1153246741@sss.pgh.pa.us> <44BD8854.9060506@calorieking.com> <15212.1153279954@sss.pgh.pa.us> <44BDB2F5.7080003@joeconway.com> <44BEA710.6060700@joeconway.com> <23198.1153367887@sss.pgh.pa.us> <44BF0382.2010501@joeconway.com> <23454.1153370214@sss.pgh.pa.us> <44BF122F.1080200@joeconway.com> Comments: In-reply-to Joe Conway message dated "Wed, 19 Jul 2006 22:18:39 -0700" Date: Thu, 20 Jul 2006 01:39:31 -0400 Message-ID: <23927.1153373971@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/876 X-Sequence-Number: 86731 Joe Conway writes: > Tom Lane wrote: >> I think the place we'd ultimately like to get to involves changing the >> executor's Result node type to have a list of targetlists and sequence >> through those lists to produce its results > I was actually just looking at that and ended up thinking that it might > be better to deal with it one level down in ExecProject (because it is > already passing targetlists directly to ExecTargetList). I'd vote against that, because (a) ExecProject is used by all executor node types, and we shouldn't add overhead to all of them for the benefit of one; (b) ExecProject doesn't actually have any internal state at the moment. To keep track of which targetlist to evaluate next, it would not only need some internal state, it would have to be told the current "es_direction". This stuff fits much better at the exec node level --- again, I'd suggest looking at Append for a comparison. But really the executor part of this is not the hard part; what we need to think about first is what's the impact on the Query datastructure that the parser/rewriter/planner use. I'm still liking the idea of pushing multi-values into a jointree node type. Basically this would suggest representing "VALUES ..." as if it were "SELECT * FROM VALUES ..." (which I believe is actually legal syntax per spec) --- in the general case you'd need to have a Query node that has a trivial "col1, col2, col3, ..." targetlist and then the multiple values lists are in some kind of jointree entry. But possibly this could be short-circuited somehow, at least for INSERT. BTW, I noticed an interesting property of historical Postgres behavior: you can put a table reference into a VALUES targetlist. regression=# create table foo (like tenk1); CREATE TABLE regression=# insert into foo values (tenk1.*); ERROR: missing FROM-clause entry for table "tenk1" LINE 1: insert into foo values (tenk1.*); ^ regression=# set add_missing_from to 1; SET regression=# insert into foo values (tenk1.*); NOTICE: adding missing FROM-clause entry for table "tenk1" LINE 1: insert into foo values (tenk1.*); ^ INSERT 0 10000 regression=# So that last is really exactly equivalent to insert into foo select * from tenk1; I do not feel a need to support this sort of thing when there are multiple VALUES targetlists, but it'd be nice not to break it for the single-targetlist case. At least not till we're ready to disable add_missing_from entirely. regards, tom lane