Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cy2Qk-0001AB-TS for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Apr 2017 20:30:27 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cy2Qk-0002v9-6b for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Apr 2017 20:30:26 +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 1cy2PF-0000Bs-Bu for pgsql-hackers@postgresql.org; Tue, 11 Apr 2017 20:28:53 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cy2PB-0002Y2-DU for pgsql-hackers@postgresql.org; Tue, 11 Apr 2017 20:28:51 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 8C07921C27FD; Tue, 11 Apr 2017 23:28:46 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru Received: from localhost (unknown [92.243.181.54]) by mail.postgrespro.ru (Postfix) with ESMTPSA id 463AC21C26F8; Tue, 11 Apr 2017 23:28:46 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1491942526; bh=O4MoDuko2ZdR0+iAhtrZ6kTXnUXulHSRzR7l88MRZlw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Lfc+MYlp65SItUIDSdgAV43Vd7x6D5Ncn+cgnt6BdpkLE3ubGLdrCv1pDhKUgLM5d TUFmuO0wgauOftfZ9SHVybM5EtUbtfM4bSk2srFuik7wJh1U7gAyJBlS3XTa2ZYuFf gXTvG+vfYRGpvTQJeR6ejtTnn4snSMRTnzNhOUsQ= From: Dmitry Ivanov To: Tom Lane Cc: Dmitry Ivanov , pgsql-hackers Subject: Re: Possible problem in Custom Scan API Date: Tue, 11 Apr 2017 23:28:17 +0300 MIME-Version: 1.0 Message-ID: In-Reply-To: <367.1491940070@sss.pgh.pa.us> References: <20021.1491933424@sss.pgh.pa.us> <1ef85b46-1385-4810-bb80-97cd977da1d5@postgrespro.ru> <367.1491940070@sss.pgh.pa.us> Organization: Postgres Professional User-Agent: Trojita/0.7; Qt/5.8.0; xcb; Linux; Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -2.0 (--) 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 Tom Lane wrote: > Reading between the lines, I think the problem may be that you're not > being careful about how you set up custom_scan_tlist. But since the > core code has zero involvement in that decision, it's hard to see why > it would be a core code bug. I'm sorry, but you didn't understand. It's *the core code* that builds the= =20 targetlist, and sometimes it may decide to provide a physical targetlist,=20 not the one that's *really needed*. The broader targetlist has Vars that=20 cannot be supplied by the IndexOnlyScan node, hence the error. We cannot come up with our own targetlist because we don't know if it's a=20 top node and we should return exactly the same tuple (CP_EXACT_TLIST) or=20 it's just the stray optimization that made us think so. Append works only because it doesn't allow projections, and it can never=20 get a physical targetlist if an index doesn't contain all columns. But everything changes when we use CustomScan: PostgreSQL will not pay=20 attention. For example, if our CustomScan is a child of NestLoop, the=20 former will call this (create_nestloop_plan): inner_plan =3D create_plan_recurse(root, best_path->innerjoinpath, 0); Since NestLoop can make projections, it doesn't enforce CP_EXACT_TLIST=20 flag, and our CustomScan may end up with a full physical targetlist (see=20 the code of create_scan_plan() if you don't believe me), INSTEAD OF the one= =20 it really has been asked to produce. Meanwhile, Append will behave as it=20 should, since it doesn't care about physical tlists. It's not just my imagination. --=20 Dmitry Ivanov Postgres Professional: http://www.postgrespro.com Russian Postgres Company --=20 Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers