Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gDKuM-0003H7-Fq for pgsql-bugs@arkaria.postgresql.org; Fri, 19 Oct 2018 02:53:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gDKuK-0006aW-8r for pgsql-bugs@arkaria.postgresql.org; Fri, 19 Oct 2018 02:53:00 +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_SHA384:256) (Exim 4.89) (envelope-from ) id 1gDKuK-0006aP-2w for pgsql-bugs@lists.postgresql.org; Fri, 19 Oct 2018 02:53:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gDKuH-0001TI-8N for pgsql-bugs@lists.postgresql.org; Fri, 19 Oct 2018 02:52:59 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w9J2qpow008214; Thu, 18 Oct 2018 22:52:51 -0400 From: Tom Lane To: Amit Langote cc: skaurus@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15437: Segfault during insert into declarative partitioned table with a trigger creating partition In-reply-to: References: <15437-3fe01ee66bd1bae1@postgresql.org> Comments: In-reply-to Amit Langote message dated "Fri, 19 Oct 2018 11:40:34 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <8212.1539917571.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 18 Oct 2018 22:52:51 -0400 Message-ID: <8213.1539917571@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Amit Langote writes: > On 2018/10/18 20:57, PG Bug reporting form wrote: >> I tried to use declarative partitioning and, to avoid creating partitio= ns by >> hand, to make them in ON BEFORE STATEMENT trigger. Trigger executes >> successfully (proved that with RAISE NOTICE), but server crashes. > The problem here is with the server allowing to create a partition of th= e > table being inserted into, inside the table's BEFORE INSERT trigger. > Generally speaking, the command that's run inside the trigger shouldn't > have been allowed to proceed if it might change the table's properties > that the execution of the ongoing command is depending upon. Check. > I propose the attached to fix that. Hmm ... I wonder if we shouldn't do CheckTableNotInUse for *both* cases, is_partition or no? regards, tom lane