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 1lZdww-000687-Fh for pgsql-bugs@arkaria.postgresql.org; Thu, 22 Apr 2021 18:21:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lZdwv-0000gQ-Df for pgsql-bugs@arkaria.postgresql.org; Thu, 22 Apr 2021 18:21:13 +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 1lZdwv-0000gJ-7b for pgsql-bugs@lists.postgresql.org; Thu, 22 Apr 2021 18:21:13 +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 1lZdwt-0006Or-0b for pgsql-bugs@lists.postgresql.org; Thu, 22 Apr 2021 18:21:12 +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 13MIL5Zc1102102; Thu, 22 Apr 2021 14:21:05 -0400 From: Tom Lane To: Amit Langote cc: David Steele , Pavel Biryukov <79166341370@yandex.ru>, Andres Freund , PostgreSQL mailing lists Subject: Re: posgres 12 bug (partitioned table) In-reply-to: References: <141051591267657@mail.yandex.ru> <1251598.1591289850@sss.pgh.pa.us> <20200811180231.fcssvhelqpnydnx7@alap3.anarazel.de> <81885.1597205290@sss.pgh.pa.us> <20200812162718.ycxrktzoe6rpdy5k@alap3.anarazel.de> <407111603806900@mail.yandex.ru> <793243.1619032209@sss.pgh.pa.us> Comments: In-reply-to Amit Langote message dated "Thu, 22 Apr 2021 21:17:08 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1102100.1619115665.1@sss.pgh.pa.us> Date: Thu, 22 Apr 2021 14:21:05 -0400 Message-ID: <1102101.1619115665@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Amit Langote writes: > On Thu, Apr 22, 2021 at 4:10 AM Tom Lane wrote: >> In the meantime, if the back branches fail with something like >> "virtual tuple table slot does not have system attributes" when >> trying to do this, that's not great but I'm not sure we should >> be putting effort into improving it. > Got it. That sounds like an acceptable compromise. Hm, we're not done with this. Whatever you think of the merits of throwing an implementation-level error, what's actually happening in v12 and v13 in the wake of a71cfc56b is that an attempt to do "RETURNING xmin" works in a non-cross-partition UPDATE, but in a cross-partition UPDATE it dumps core. What I'm seeing is that the result of the execute_attr_map_slot() call looks like (gdb) p *(BufferHeapTupleTableSlot*) scanslot $3 = {base = {base = {type = T_TupleTableSlot, tts_flags = 8, tts_nvalid = 3, tts_ops = 0xa305c0 , tts_tupleDescriptor = 0x7f1c7798f920, tts_values = 0x2077100, tts_isnull = 0x2075fb0, tts_mcxt = 0x2015ea0, tts_tid = {ip_blkid = { bi_hi = 0, bi_lo = 0}, ip_posid = 3}, tts_tableOid = 37812}, tuple = 0x0, off = 0, tupdata = {t_len = 0, t_self = {ip_blkid = { bi_hi = 0, bi_lo = 0}, ip_posid = 0}, t_tableOid = 0, t_data = 0x0}}, buffer = 0} and since base.tuple is NULL, heap_getsysattr dies on either "Assert(tup)" or a null-pointer dereference. So (1) It seems like this is exposing a shortcoming in the multiple-slot-types logic. It's not hard to understand why the slot would look like this after execute_attr_map_slot does ExecStoreVirtualTuple, but if this is not a legal state for a BufferHeapTuple slot, why didn't ExecStoreVirtualTuple raise a complaint? (2) It also seems like we can't use the srcSlot if we want to have the fail-because-its-a-virtual-tuple behavior. I experimented with doing ExecMaterializeSlot on the result of execute_attr_map_slot, and that stops the crash, but then we're returning garbage values of xmin etc, which does not seem good. regards, tom lane