Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fIO86-0008ED-Un for pgsql-hackers@arkaria.postgresql.org; Tue, 15 May 2018 00:47:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fIO85-00075r-LH for pgsql-hackers@arkaria.postgresql.org; Tue, 15 May 2018 00:47:49 +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.89) (envelope-from ) id 1fIO85-00075i-BD for pgsql-hackers@lists.postgresql.org; Tue, 15 May 2018 00:47:49 +0000 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fIO81-0002ac-RD for pgsql-hackers@lists.postgresql.org; Tue, 15 May 2018 00:47:48 +0000 Received: from vc2.ecl.ntt.co.jp (vc2.ecl.ntt.co.jp [129.60.86.154]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id w4F0lfZc020858; Tue, 15 May 2018 09:47:41 +0900 Received: from vc2.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 43EE9638535; Tue, 15 May 2018 09:47:41 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 380B7638521; Tue, 15 May 2018 09:47:41 +0900 (JST) Received: from [127.0.0.1] (unknown [129.60.241.61]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id 2CE54400A98; Tue, 15 May 2018 09:47:41 +0900 (JST) Subject: Re: Indexes on partitioned tables and foreign partitions References: <20180514172910.wjuvrtcdhcc5y3u7@alvherre.pgsql> From: Amit Langote Message-ID: Date: Tue, 15 May 2018 09:47:24 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180514172910.wjuvrtcdhcc5y3u7@alvherre.pgsql> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CC-Mail-RelayStamp: 1 To: Alvaro Herrera Cc: Michael Paquier , Tom Lane , Robert Haas , Simon Riggs , Arseny Sher , "pgsql-hackers@lists.postgresql.org" X-TM-AS-MML: disable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018/05/15 2:29, Alvaro Herrera wrote: > On 2018-May-10, Amit Langote wrote: > >> How about we error out even *before* calling DefineIndex for the 1st time? >> I see that ProcessUtilitySlow() gets a list of all partitions when >> locking them for index creation before calling DefineIndex. Maybe, just >> go through the list and error out if one of them is a partition that we >> don't support creating an index on? > > The overwhelming consensus seems to be for this option, so I pushed your > patch after some small tweaks -- mostly to simplify unnecessarily > baroque code. (I must have been thinking that recursion would happen > right in ProcessUtilitySlow. That doesn't match my memories, but I > can't explain this code otherwise.) I added a very small test too. Thank you. > I think it'd be better to take this out of ProcessUtility also and into > DefineInde, for cleanliness sake; maybe add a 'recursing' flag to > DefineIndex. Not for pg11, though. Agreed. Most of the stuff in utility.c is for command dispatch and there is no reason for this partitioning-related bit to be sitting here. Moving it will require perhaps non-trivial adjustment of indexcmds.c code, so let's leave it for later as you say. Thanks, Amit