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 1t3yNk-00FgFL-8v for pgsql-hackers@arkaria.postgresql.org; Thu, 24 Oct 2024 14:00:08 +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 1t3yNi-003YXX-JB for pgsql-hackers@arkaria.postgresql.org; Thu, 24 Oct 2024 14:00:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3yNi-003YXP-At for pgsql-hackers@lists.postgresql.org; Thu, 24 Oct 2024 14:00:06 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t3yNg-002dEv-8q for pgsql-hackers@postgresql.org; Thu, 24 Oct 2024 14:00:05 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-539e4b7409fso1072757e87.0 for ; Thu, 24 Oct 2024 07:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729778402; x=1730383202; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=EYduej5UirEPfAMtjSinsERv58te2M+H3cEChcbV3SA=; b=eORNE9aVpEBhwnH5SIFRkEZ/NlrRzawl78+wgTBpGyiCP2ZeAUSPJkFQOb2lpf4C75 WKkv49KTK3EUwvuCk2LezyScHmRv474it8AeXOo81UZVvApojnNQeGIKvFWpUWCgsvY0 PnylJAvwaN9vc186VxY904MopkM6RXrQGjXRVyBiDxquBTIrbyOvBA45OcDKgFcbaKvb p7yin7IZanFCQtxADnHeZ+OxCOaDsRoC4lVu67eyx+27V7ZSf0kM9SNwvvsCQkdfUbr3 Dw1+I6UEilx1gNJ/ElWOlEKHrXu6SbJqWeJkBm8sjFe+itCvJi0H+XMqHPh7296jj5iI TzUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729778402; x=1730383202; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EYduej5UirEPfAMtjSinsERv58te2M+H3cEChcbV3SA=; b=wKWmuUUQhk7DDDsI5eH+vep/5L4aurXAg0NdgQFNimOAwcWUaMdgpzLdEabysEjBv1 wpU51cGOxl2JNcoz5q8/aY6hs/HcNi6dOwTn3qNl4WiPMUGedRNaZuMdu/bKxWnj6lS2 ah8+YmomKrg6tt2zB2UL42LfSS4s2yBOVCu3mKhRXAI+LAm2oupXBNkap/lBUgL1Y0QP YEctnPoih6OMyI8vG4a6HOJvdKgUrA1Bc87q0tUmO1UsPI+1Uq47S2BKWz+bvXY0Hdsc 6fDhx1s1KbN8qRgPmdM+hV3EHruauWbpCdEPLkbgvLARAvViwRGY8zuDwHsSVrLKo7rK GFsA== X-Forwarded-Encrypted: i=1; AJvYcCUEIiA17k7ghH0CkVaDVmst1sQMOWfB8Yx65nPWVebuTLbipdDFMqwHFlQJsfTNLceZUQfRyH0DhP4MxRaS@postgresql.org X-Gm-Message-State: AOJu0Ywci9mrjkZYkimwvf8m972V9k2Bz+vj1OPHRPwoPWt9x5CxBqVa ueMAJY4lVv1AWPAQVIKL5xosz3YBzOVs1idoNqT6lgoG8LummDZJ X-Google-Smtp-Source: AGHT+IFfpO6cJ5AnUuvQJ2BycLD+y9Jvh3MOvnawQvFoMuHyTNWxDq4/VK0b3/uS40QXzAbDpTALRg== X-Received: by 2002:a05:6512:39c8:b0:539:e4ad:8bab with SMTP id 2adb3069b0e04-53b2372a85amr786950e87.16.1729778402141; Thu, 24 Oct 2024 07:00:02 -0700 (PDT) Received: from [1.0.0.7] ([178.155.29.188]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53a22440419sm1371427e87.270.2024.10.24.07.00.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Oct 2024 07:00:01 -0700 (PDT) Message-ID: <461e9c26-2076-8224-e119-84998b6a784e@gmail.com> Date: Thu, 24 Oct 2024 17:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails Content-Language: en-US To: Alvaro Herrera Cc: Jehan-Guillaume de Rorthais , Tender Wang , Junwang Zhao , "pgsql-hackers@postgresql.org" , Guillaume Lelarge , Michael Paquier References: <202410221432.3qtqbk2q6o7q@alvherre.pgsql> From: Alexander Lakhin In-Reply-To: <202410221432.3qtqbk2q6o7q@alvherre.pgsql> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello Alvaro, 22.10.2024 17:32, Alvaro Herrera wrote: > Yeah. I pushed these patches finally, thanks! Please look at a new anomaly introduced with 53af9491a. When running the following script: CREATE TABLE t (a int, b int, PRIMARY KEY (a, b)); CREATE TABLE pt (a int, b int, FOREIGN KEY (a, b) REFERENCES t(a, b))  PARTITION BY LIST (a); CREATE TABLE tp1 (x int, a int, b int); ALTER TABLE tp1 DROP COLUMN x; ALTER TABLE pt ATTACH PARTITION tp1 FOR VALUES IN (1); ALTER TABLE pt DETACH PARTITION tp1; I get a memory access error detected by Valgrind: 2024-10-24 12:05:04.645 UTC [1079077] LOG:  statement: ALTER TABLE pt DETACH PARTITION tp1; ==00:00:00:07.887 1079077== Invalid read of size 2 ==00:00:00:07.887 1079077==    at 0x4A61DD: DetachPartitionFinalize (tablecmds.c:19545) ==00:00:00:07.887 1079077==    by 0x4A5C11: ATExecDetachPartition (tablecmds.c:19386) ==00:00:00:07.887 1079077==    by 0x48561E: ATExecCmd (tablecmds.c:5540) ==00:00:00:07.887 1079077==    by 0x4845DE: ATRewriteCatalogs (tablecmds.c:5203) ==00:00:00:07.887 1079077==    by 0x4838EC: ATController (tablecmds.c:4758) ==00:00:00:07.887 1079077==    by 0x4834F1: AlterTable (tablecmds.c:4404) ==00:00:00:07.887 1079077==    by 0x7D6D52: ProcessUtilitySlow (utility.c:1318) ==00:00:00:07.887 1079077==    by 0x7D65F7: standard_ProcessUtility (utility.c:1067) ==00:00:00:07.887 1079077==    by 0x7D54F7: ProcessUtility (utility.c:523) ==00:00:00:07.887 1079077==    by 0x7D3D70: PortalRunUtility (pquery.c:1158) ==00:00:00:07.887 1079077==    by 0x7D3FE7: PortalRunMulti (pquery.c:1316) ==00:00:00:07.887 1079077==    by 0x7D3431: PortalRun (pquery.c:791) Reproduced on REL_15_STABLE .. master. Best regards, Alexander