Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cTCaA-0002jG-VJ for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Jan 2017 19:04:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cTCaA-00073R-Gn for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Jan 2017 19:04:42 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cTCa9-00073K-Hv for pgsql-hackers@postgresql.org; Mon, 16 Jan 2017 19:04:41 +0000 Received: from mail-qt0-x22c.google.com ([2607:f8b0:400d:c0d::22c]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cTCa6-0004EO-CH for pgsql-hackers@postgresql.org; Mon, 16 Jan 2017 19:04:39 +0000 Received: by mail-qt0-x22c.google.com with SMTP id k15so116493770qtg.3 for ; Mon, 16 Jan 2017 11:04:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=emmZOR20TD+aKBQ4jJ+GZ1bmuUlInNqF8TnJJswqzRg=; b=rAdFNfPfrM5/FtqsYjrcA+3Ymnyt0tdqG2jYgxW1m8bT52YDz8+tW135p8gYH6EQG2 SRAvKogApGqQJAMNfz49Cgls3LJtKxwH0mJs2NThc4o8cbOAsA5BiYDd/PzHUOPykBru CDmnY1MliIpbiOVvCL18mdBeTzlixpXQZej+d3uv8DCxIpyLoIWVAsAgrzCbUMelXYJz Q6UUfmKVu3j6pSuzsn9NZ3n4gWIyqDWNM8NUK/FMDOiANbYekqIloinqz18eHvaIxVTn 8VaJRaTnx0HbwhOSG++7bZosF5csqMFvV0oNWYZHF+twnRUE2lasIxO7LQkE+h+vKTPh kVeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=emmZOR20TD+aKBQ4jJ+GZ1bmuUlInNqF8TnJJswqzRg=; b=WsDGgAlhVBoIrv8v7ZFvAKotEEVH7EZ90ByLbhwLnA8v48NqqfrqgK665LJR9nDvnp 2JW+O+XxNZIm1hiorsMv+BO3l9x8CGPTPIyiMbdpwslTdTSp9Rjk9mWGYBHhXoc0OBix sAg2TfUE1ugVsweo1vYSDUfTHksXQrAfX08DxcXU8RTzbbGniZWqVyyR9+/JA7pnX4+i VOx13VzgEWm1oeCuNzjLQAvJD89y+0YQ4e/ZfhIBJjsNdJvP7u2d/qPQLTTlBeikQAZx IplBOAUenatvIwmrl4A5399Oc2W1/OM5OQ4h8fwqaZhRMgboXG2/jTv5+3KHjIMjzzir 9rnw== X-Gm-Message-State: AIkVDXIQvVzGsmCHKLp+AJtZmfGsFjFKITPZ/FCCv3oJRR5e+HT362kyK8l+W+bvfgqd2PAX X-Received: by 10.55.128.5 with SMTP id b5mr6515007qkd.319.1484593476890; Mon, 16 Jan 2017 11:04:36 -0800 (PST) Received: from alvin.alvh.no-ip.org ([179.57.112.237]) by smtp.gmail.com with ESMTPSA id o44sm16903167qtc.8.2017.01.16.11.04.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jan 2017 11:04:36 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 323B727C0; Mon, 16 Jan 2017 16:04:34 -0300 (CLST) Date: Mon, 16 Jan 2017 16:04:34 -0300 From: Alvaro Herrera To: Andres Freund Cc: Tom Lane , pgsql-hackers@postgresql.org Subject: Re: Implement targetlist SRFs using ROWS FROM() (was Changed SRF in targetlist handling) Message-ID: <20170116190434.7xcy7oxpubfw7mys@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20170116184417.esbyb6lzkotpibam@alap3.anarazel.de> User-Agent: NeoMutt/20161104 (1.7.1) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Andres Freund wrote: > On 2017-01-16 12:17:46 -0300, Alvaro Herrera wrote: > > Andres Freund wrote: > > > > > That worked quite well. So we have a few questions, before I clean this > > > up: > > > > > > - For now the node is named 'Srf' both internally and in explain - not > > > sure if we want to make that something longer/easier to understand for > > > others? Proposals? TargetFunctionScan? SetResult? > > > > > > - We could alternatively add all this into the Result node - it's not > > > actually a lot of new code, and most of that is boilerplate stuff > > > about adding a new node. I'm ok with both. > > > > Hmm. I wonder if your stuff could be used as support code for > > XMLTABLE[1]. > > I don't immediately see what functionality overlaps, could you expand on > that? Well, I haven't read any previous patches in this area, but the xmltable patch adds a new way of handling set-returning expressions, so it appears vaguely related. These aren't properly functions in the current sense of the word, though. There is some parallel to what ExecMakeFunctionResult does, which I suppose is related. > > Currently it has a bit of additional code of its own, > > though admittedly it's very little code executor-side. Would you mind > > sharing a patch, or more details on how it works? > > Can do both; cleaning up the patch now. What we're talking about here is > a way to implement targetlist SRF that is based on: > > 1) a patch by Tom that creates additional Result (or now Srf) executor > nodes containing SRF evaluation. This guarantees that only Result/Srf > nodes have to deal with targetlist SRF evaluation. > > 2) new code to evaluate SRFs in the new Result/Srf node, that doesn't > rely on ExecEvalExpr et al. to have a IsDone argument. Instead > there's special code to handle that in the new node. That's possible > because it's now guaranted that all SRFs are "toplevel" in the > relevant targetlist(s). > > 3) Removal of all nearly tSRF related code execQual.c and other > executor/ files, including the node->ps.ps_TupFromTlist checks > everywhere. > > makes sense? Hmm, okay. (The ps_TupFromTlist thing has long seemed an ugly construction.) I think the current term for this kind of thing is TableFunction -- are you really naming this "Srf" literally? It seems strange, but maybe it's just me. > > Nested targetlist SRFs make my head spin. I suppose they may have some > > use, but where would you really want this: > > I think there's some cases where it can be useful. Targetlist SRFs as a > whole really are much more about backward compatibility than anything :) Sure. > > ? If supporting the former makes it harder to support/optimize more > > reasonable cases, it seems fair game to leave them behind. > > I don't want to desupport them, just don't want to restructure (one node > doing several levels of SRFs, instead of one per level) just to make it > easier to give good estimates. No objections. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers