X-Original-To: pgsql-patches-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 10DC59FA502 for ; Mon, 24 Jul 2006 14:09:44 -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 46867-10 for ; Mon, 24 Jul 2006 14:09:36 -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 AA9CF9FA441 for ; Mon, 24 Jul 2006 14:09:36 -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 k6OH9Th6012030; Mon, 24 Jul 2006 13:09:29 -0400 (EDT) To: Joe Conway cc: Christopher Kings-Lynne , "Patches (PostgreSQL)" , Andrew Dunstan , Bernd Helmle , Peter Eisentraut , Susanne Ebrecht Subject: Re: Values list-of-targetlists patch for comments (was Re: [HACKERS] 8.2 features?) In-reply-to: <44C4F625.2050304@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> <23927.1153373971@sss.pgh.pa.us> <44C00E1E.1000405@joeconway.com> <14047.1153442773@sss.pgh.pa.us> <44C4451A.4010906@joeconway.com> <11495.1153757531@sss.pgh.pa.us> <44C4F625.2050304@joeconway.com> Comments: In-reply-to Joe Conway message dated "Mon, 24 Jul 2006 09:32:37 -0700" Date: Mon, 24 Jul 2006 13:09:29 -0400 Message-ID: <12029.1153760969@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.063 tagged_above=0 required=5 tests=AWL, SPF_HELO_PASS, SPF_PASS X-Spam-Level: X-Archive-Number: 200607/185 X-Sequence-Number: 20339 Joe Conway writes: > Good feedback -- thanks! But without the RTE, how would VALUES in the > FROM clause work? Is it different from INSERT? I'm just imagining a Values node in the jointree and nothing in the rangetable. If I'm reading the spec correctly, VALUES is exactly parallel to SELECT in the grammar, which means that to use it in FROM you would need parentheses and an alias: SELECT ... FROM (SELECT ...) AS foo SELECT ... FROM (VALUES ...) AS foo ISTM that this should be represented using an RTE_SUBQUERY node in the outer query; the alias attaches to that node, not to the VALUES itself. So I don't think you need that alias field in the jointree entry either. If we stick with the plan of representing VALUES as if it were SELECT * FROM (valuesnode), then this approach would make the second query above have a structure like Query .rtable -> RTE_SUBQUERY .subquery -> Query .jointree -> Values (leaving out a ton of detail of course, but those are the key nodes). To get this to reverse-list in the expected form, we'd need a small kluge in ruleutils.c that short-circuits the display of "SELECT ... FROM" etc when it sees a Values node at the top of the jointree. This seems like a fairly small price to pay for keeping Query in approximately its present form, though. One thought is that we might allow Query.jointree to point to either a FromExpr or a Values node, and disallow Values from appearing further down in the jointree (except perhaps after flattening of subqueries in the planner). The alternative is that there's a FromExpr atop the Values node in the jointree even in the simple case; which seems uglier but it might avoid breaking some code that expects the top level to always be FromExpr. regards, tom lane