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 1kbomH-0004fY-W9 for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Nov 2020 17:46:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kbomG-00074P-La for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Nov 2020 17:46:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kbomG-00074H-C8 for pgsql-hackers@lists.postgresql.org; Sun, 08 Nov 2020 17:46:56 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kbom9-0003pP-TF for pgsql-hackers@postgresql.org; Sun, 08 Nov 2020 17:46:55 +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 0A8HkiNL1832747; Sun, 8 Nov 2020 12:46:45 -0500 From: Tom Lane To: "Drouvot, Bertrand" cc: PostgreSQL-development , Andres Freund Subject: Re: [BUG]: segfault during update In-reply-to: <1831655.1604855899@sss.pgh.pa.us> References: <1831655.1604855899@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sun, 08 Nov 2020 12:18:19 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1832745.1604857604.1@sss.pgh.pa.us> Date: Sun, 08 Nov 2020 12:46:44 -0500 Message-ID: <1832746.1604857604@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I wrote: > Yeah, this is sufficient reason why we must use the more invasive > patch on those branches. What I'm wondering now is if there's a > way to break even-older branches based on failure to handle dropped > columns here. After tracing through the example in v11, I see why those branches are not broken: when ExecBRUpdateTriggers decides to return the trigger-returned tuple, it sticks it into a target slot like this: /* * Return the modified tuple using the es_trig_tuple_slot. We assume * the tuple was allocated in per-tuple memory context, and therefore * will go away by itself. The tuple table slot should not try to * clear it. */ TupleTableSlot *newslot = estate->es_trig_tuple_slot; TupleDesc tupdesc = RelationGetDescr(relinfo->ri_RelationDesc); if (newslot->tts_tupleDescriptor != tupdesc) ExecSetSlotDescriptor(newslot, tupdesc); ExecStoreTuple(newtuple, newslot, InvalidBuffer, false); So the slot that ExecConstraints et al will be working with contains the relation's actual tuple descriptor, not the approximate descr obtained by looking at the plan tlist. This logic is entirely gone in v12, which confirms my instinct that there was something about Andres' slot-manipulation changes that broke this scenario. In v12 we end up using the junkfilter's output slot, which does not have a sufficiently accurate tupdesc to deal with an on-disk tuple rather than one constructed by the executor. So I'll go see about back-patching 20d3fe900. regards, tom lane