Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h7BV6-0005Ln-Bi for pgsql-committers@arkaria.postgresql.org; Fri, 22 Mar 2019 04:09:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h7BV4-00072M-Np for pgsql-committers@arkaria.postgresql.org; Fri, 22 Mar 2019 04:09:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h7BV4-00072F-IN for pgsql-committers@lists.postgresql.org; Fri, 22 Mar 2019 04:09:46 +0000 Received: from tama50.ecl.ntt.co.jp ([129.60.39.147]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h7BUw-0000Sq-FB for pgsql-committers@lists.postgresql.org; Fri, 22 Mar 2019 04:09:46 +0000 Received: from vc1.ecl.ntt.co.jp (vc1.ecl.ntt.co.jp [129.60.86.153]) by tama50.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id x2M49Yxt014194; Fri, 22 Mar 2019 13:09:34 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 529A3EA7B57; Fri, 22 Mar 2019 13:09:34 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 449F1EA704C; Fri, 22 Mar 2019 13:09:34 +0900 (JST) Received: from [127.0.0.1] (unknown [129.60.241.61]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id 320E84007D2; Fri, 22 Mar 2019 13:09:34 +0900 (JST) Subject: Re: [Suspect SPAM] Re: pgsql: Add pg_partition_root to display top-most parent of a partition References: <20190322032612.GA323@alvherre.pgsql> <20190322035538.GO20192@paquier.xyz> From: Amit Langote Message-ID: <06be11a6-fd8d-b68b-1b97-1bafb1d3185c@lab.ntt.co.jp> Date: Fri, 22 Mar 2019 13:09:23 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.3 MIME-Version: 1.0 In-Reply-To: <20190322035538.GO20192@paquier.xyz> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CC-Mail-RelayStamp: 1 To: Michael Paquier , Alvaro Herrera Cc: pgsql-committers@lists.postgresql.org X-TM-AS-MML: disable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2019/03/22 12:55, Michael Paquier wrote: > On Fri, Mar 22, 2019 at 12:26:12AM -0300, Alvaro Herrera wrote: >> I noticed days ago that if you call pg_partition_root on the topmost >> partitioned table, the server crashes :-) I thought we already fixed that last month, but that was pg_partition_tree(). > It's when you think that the thing is actually done that another issue > pops up. The attached fixes the issue, I suggest to return the > top-most parent as result if the input is the top-most parent itself. > Returning NULL does not make sense as in this case the relation can be > part of a partition tree. Thanks for writing the patch. /* Fetch the top-most parent */ ancestors = get_partition_ancestors(relid); Maybe, the patch should update this comment to say "Fetch the list of ancestors". + + /* + * If the listed partition is already the top-most parent, just + * return itself. + */ What does "listed partition" mean? Maybe, you mean "If the input relation..."? How about write this as: If the input relation is itself the top-most parent, just return itself. Regards, Amit