Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t4M2Z-0007eE-7G for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Oct 2024 15:15:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t4M1Z-000knp-Hk for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Oct 2024 15:14:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t4M1Y-000kkb-GJ for pgsql-hackers@lists.postgresql.org; Fri, 25 Oct 2024 15:14:49 +0000 Received: from fhigh-a4-smtp.messagingengine.com ([103.168.172.155]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t4M1V-002w0s-9K for pgsql-hackers@postgresql.org; Fri, 25 Oct 2024 15:14:48 +0000 Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id 43B6511400FE; Fri, 25 Oct 2024 11:14:43 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-09.internal (MEProxy); Fri, 25 Oct 2024 11:14:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1729869283; x= 1729955683; bh=fYiVJvU7cycjkd9G92ABVpH7SNgkT+tLJ2yKzRJHpZc=; b=g Rjn1GTo1wkI5WXZ4QP4d2N89GDBNtreNy5o2w8F7Vs8q928tITtjq21h9M524hfJ z6sOveWZiosohi2TW7ImohE5ih4Dq8fTkdNQkvDphI4FXcQe93+gBqVri1GuTCyf LeDih0eDtA4jhMTAmwoGQC7pLDbUc3o6m1M+Yc8PNHVPJNP5Mtav4QfayjZzDblV ZXXWfJUZMFvY5x8t+w8SdZAscu3dvo/yR9VDrWRC93pXBK5QXeUknn2glYgnV7Bu woZfrii/UVuSmSn5+3O6Ltn35YGR5k5hYNvyekdw34cwj41Z7+xA88pvLf1qCHog DnfyyZzFxcjE69L7EE+BA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdejvddgkeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeen ucfhrhhomheptehlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhh drnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepvdektdffudfftdffffehfffh jeejhffgieeuueekjeekfffgudffhfduffffueevnecuffhomhgrihhnpegvnhhtvghrph hrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgr ihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgpdhnsggprh gtphhtthhopeejpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehjghgurhesuggr lhhisghordgtohhmpdhrtghpthhtohepvgigtghluhhsihhonhesghhmrghilhdrtghomh dprhgtphhtthhopehtnhgurhifrghnghesghhmrghilhdrtghomhdprhgtphhtthhopeii hhhjfihpkhhusehgmhgrihhlrdgtohhmpdhrtghpthhtohepghhuihhllhgruhhmvgeslh gvlhgrrhhgvgdrihhnfhhopdhrtghpthhtohepmhhitghhrggvlhesphgrqhhuihgvrhdr giihiidprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehpohhsthhgrhgvshhqlh drohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 25 Oct 2024 11:14:42 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1729869277; bh=ekSXQnI5BOzFsluVNHBsn3uh6zo+fAMEUXhkUqHz/ms=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=AQsgPIIOlDA6fJhLLxZBtpiUdE5i6AvpuDWdBVMAQQrLby5bV8uDCSnT4XmxAzr7U gfGdOHkbparS1mnJX0XdZfi5bZdcg7+o0lq/FWUg/73WaoS59krubKhSR/FFpSy4s7 K3Rls34EbwqivBoHCPe6SSlGxonT+5KMfZpFLwckvb2bYzsp0WGaQpPVczmjXe27yg o3rSlNiLv1oyM486n8En1xg2twVxcMJjcfHmZZtoK51asfyRuhSqLsQcpda+T+KVsF aO56NWeL4TNOqq45KkZfzi36d2fYVMV7Z1lndjR4ChAlsnyNAPWBRAl4U3fA82x5im Yx16zgB3UkTBg== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id D25638B; Fri, 25 Oct 2024 17:14:37 +0200 (CEST) Date: Fri, 25 Oct 2024 17:14:37 +0200 From: Alvaro Herrera To: Alexander Lakhin Cc: Tender Wang , Jehan-Guillaume de Rorthais , Junwang Zhao , "pgsql-hackers@postgresql.org" , Guillaume Lelarge , Michael Paquier Subject: Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails Message-ID: <202410251514.5yabwwj2uc2e@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-Oct-25, Alexander Lakhin wrote: > I've also discovered another anomaly with a similar setup, but it's not > related to 53af9491a. Hmm, it may well be a preexisting problem, but I do think it involves the same code. As far as I can tell, the value "2" here > This script ends up with: > ERROR:  invalid attribute number 2 > ERROR:  cache lookup failed for attribute 2 of relation 16398 is coming from riinfo->confdelsetcols which was set up by DetachPartitionFinalize during the last DETACH operation. > (Perhaps it deserves a separate discussion.) No need for that. A backtrace from the errfinish gives me this (apologies for the wide terminal): #0 errfinish (filename=0x5610d93e4510 "../../../../../pgsql/source/master/src/backend/parser/parse_relation.c", lineno=3618, funcname=0x5610d93e5518 <__func__.5> "attnumAttName") at ../../../../../../pgsql/source/master/src/backend/utils/error/elog.c:475 #1 0x00005610d8d68bcc in attnumAttName (rd=rd@entry=0x7f69dd0c1a90, attid=2) at ../../../../../pgsql/source/master/src/backend/parser/parse_relation.c:3618 #2 0x00005610d924a8c5 in ri_set (trigdata=0x7ffe38d924c0, is_set_null=, tgkind=) at ../../../../../../pgsql/source/master/src/backend/utils/adt/ri_triggers.c:1219 #3 0x00005610d8f897ea in ExecCallTriggerFunc (trigdata=trigdata@entry=0x7ffe38d924c0, tgindx=tgindx@entry=2, finfo=0x5611153f5768, finfo@entry=0x5611153f5708, instr=instr@entry=0x0, per_tuple_context=per_tuple_context@entry=0x561115471c30) at ../../../../../pgsql/source/master/src/backend/commands/trigger.c:2362 #4 0x00005610d8f8b646 in AfterTriggerExecute (trig_tuple_slot2=0x0, trig_tuple_slot1=0x0, per_tuple_context=0x561115471c30, instr=0x0, finfo=0x5611153f5708, trigdesc=0x5611153f53e8, dst_relInfo=, src_relInfo=, relInfo=0x5611153f51d8, event=0x56111546fd4c, estate=0x5611153f4d50) at ../../../../../pgsql/source/master/src/backend/commands/trigger.c:4498 #5 afterTriggerInvokeEvents (events=events@entry=0x5611154292a0, firing_id=1, estate=estate@entry=0x5611153f4d50, delete_ok=delete_ok@entry=false) at ../../../../../pgsql/source/master/src/backend/commands/trigger.c:4735 #6 0x00005610d8f8ff10 in AfterTriggerEndQuery (estate=estate@entry=0x5611153f4d50) at ../../../../../pgsql/source/master/src/backend/commands/trigger.c:5090 #7 0x00005610d8fb2457 in standard_ExecutorFinish (queryDesc=0x561115460810) at ../../../../../pgsql/source/master/src/backend/executor/execMain.c:442 #8 0x00005610d917df48 in ProcessQuery (plan=0x56111545ef50, sourceText=0x56111539cfb0 "DELETE FROM t;", params=0x0, queryEnv=0x0, dest=0x56111545f0b0, qc=0x7ffe38d92830) at ../../../../../pgsql/source/master/src/backend/tcop/pquery.c:193 and then (gdb) frame 2 #2 0x00005610d924a8c5 in ri_set (trigdata=0x7ffe38d924c0, is_set_null=, tgkind=) at ../../../../../../pgsql/source/master/src/backend/utils/adt/ri_triggers.c:1219 1219 quoteOneName(attname, RIAttName(fk_rel, set_cols[i])); (gdb) print *riinfo $5 = {constraint_id = 16400, valid = true, constraint_root_id = 16400, oidHashValue = 3001019032, rootHashValue = 3001019032, conname = { data = "pt_a_fkey", '\000' }, pk_relid = 16384, fk_relid = 16397, confupdtype = 97 'a', confdeltype = 100 'd', ndelsetcols = 1, confdelsetcols = {2, 0 }, confmatchtype = 115 's', hasperiod = false, nkeys = 1, pk_attnums = {1, 0 }, fk_attnums = {1, 0 }, pf_eq_oprs = {96, 0 }, pp_eq_oprs = {96, 0 }, ff_eq_oprs = {96, 0 }, period_contained_by_oper = 0, agged_period_contained_by_oper = 0, valid_link = {prev = 0x5611153f4c30, next = 0x5610d96b51b0 }} -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ "Digital and video cameras have this adjustment and film cameras don't for the same reason dogs and cats lick themselves: because they can." (Ken Rockwell)