Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1op8XJ-0002YF-Ja for pgsql-hackers@arkaria.postgresql.org; Sun, 30 Oct 2022 13:39:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1op8XG-0003yl-HI for pgsql-hackers@arkaria.postgresql.org; Sun, 30 Oct 2022 13:39:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1op8XG-0003wT-7q for pgsql-hackers@lists.postgresql.org; Sun, 30 Oct 2022 13:39:34 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1op8X6-0004gX-U6 for pgsql-hackers@lists.postgresql.org; Sun, 30 Oct 2022 13:39:29 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 29UDdLPC188735; Sun, 30 Oct 2022 09:39:21 -0400 From: Tom Lane To: Dilip Kumar cc: ilya.v.gladyshev@gmail.com, pgsql-hackers@lists.postgresql.org Subject: Re: Segfault on logical replication to partitioned table with foreign children In-reply-to: References: <6b93e3748ba43298694f376ca8797279d7945e29.camel@gmail.com> Comments: In-reply-to Dilip Kumar message dated "Sun, 30 Oct 2022 15:16:01 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <188733.1667137161.1@sss.pgh.pa.us> Date: Sun, 30 Oct 2022 09:39:21 -0400 Message-ID: <188734.1667137161@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dilip Kumar writes: > Yes, this looks like a bug and your fix seems correct to me. It would > be nice to add a test case for this scenario. A test case doesn't seem that exciting to me. If we were trying to make it actually work, then yeah, but throwing an error isn't that useful to test. The code will be exercised by replication to a regular partitioned table (I assume we do have tests for that). What I'm wondering about is whether we can refactor this code to avoid so many usually-useless catalog lookups. Pulling the namespace name, in particular, is expensive and we generally are not going to need the result. In the child-rel case it'd be much better to pass the opened relation and let the error-check subroutine work from that. Maybe we should just do it like that at the start of the recursion, too? Or pass the relid and let the subroutine look up the names only in the error case. A completely different line of thought is that this doesn't seem like a terribly bulletproof fix, since children could get added to a partitioned table after we look. Maybe it'd be better to check the relkind at the last moment before we do something that depends on a child table being a relation. regards, tom lane