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 1tZlU4-00CnMf-Jx for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Jan 2025 06:42:05 +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 1tZlU1-00CxnO-Ac for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Jan 2025 06:42:01 +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 1tZlU0-00CxnG-VU for pgsql-hackers@lists.postgresql.org; Mon, 20 Jan 2025 06:42:01 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tZlTy-000US1-04 for pgsql-hackers@postgresql.org; Mon, 20 Jan 2025 06:42:00 +0000 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-2ee50ffcf14so8022180a91.0 for ; Sun, 19 Jan 2025 22:41:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737355316; x=1737960116; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0gSio8/04xS9PXmsU5et++WrQpkQW4wBI4RtImsgPyM=; b=ddgBNkPbMlen9uArTcco+jbdHUgKoZr/aV15903jSxSDsF4339g70Gy4RmrjZ6Rqln MPE3vdZ2Li6w9zy7QnTaf+5AaDA7CTIDeGeNpWG7wT1igbNK7hKMO+TrZRjZZgwo0Zp9 zF1PeUi0w8LeA7lmiBXpIjn2V5TCZmntlp1lI1SdaPflYGZMTEyx3MxjYgc8dMXDthaP UExNZpfmjNCRmPsXO3PfnOC9CqO55v1l19GTe8Q3C9X9xpyFfKZtUWhHOv4Sqjlscy8B 16IFv6S57y7PEcXLwykRcmXe/t+WC0suPGh/RaeUcca1roiuRGhK8atH+Qfl5xAYLjBN OuoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737355316; x=1737960116; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0gSio8/04xS9PXmsU5et++WrQpkQW4wBI4RtImsgPyM=; b=MSokITuVLL3zUKO6u8ys8hg80/ie+Ut/bXvw2zWZGAbs8qmzDQ8bv+DuPMIYUBMQKl ZmlRNzNrm16uBXBotQcs/pado/Pj1ngy5zoluM8QH9U/kXkxBzAevyI5pVhqByFDaGmz KlP8QLw5/EFLUy8cxVDdBR2E9D0X1XkqmDb4Uo/4jwSRoIqOYgq4N0Qqwl6MmtvbyVWn S5bc8O4eS1+WIxcGPyyg5wc2DfGHCaQgYt/Qr4yHEx29WCGl68GGaV+1tc038sOqmm/y 2f11Ek1vi86iKp9fWAgzysVc3a+EOgeKDNaEcVN4Sguk+sviAzhNuCXUS3opgib0PSpe VzWg== X-Gm-Message-State: AOJu0YzfPIlURAUj8W9C4xlbeY1JdfOnFYk2VqeFSk+N4/keMA6ks0hj +mnvqfimpdNfPgbfBf1vPo1maOerinkGDY76xLafzhrWw/630w2w1/vGeoOIUpngySJiPZ/uTNB YwzXaRfN9vbZsOYtNaWoEbSSz61o= X-Gm-Gg: ASbGncv1iUfX+awRAbVi+QreFKqpXUa6/HBK7n0e2r0m55LdS7OayV/oOA6tC5q9hNN YJlJdt3a7Qs91NcffAPrCe1mxDW+4o5xDrFwzhaj6hDCHNyuLPrClyA9l/TBgvlzQWYVAFGbeYU rLGuNQL3RwRQ== X-Google-Smtp-Source: AGHT+IFuOKR+vtuCgQqm+WWQgwnZ2sGBGSVkCbNWoNHaA97jh/0nfPlM3cPo5WvWVExr/DKAw1hmPb1MRAmXjM/u7ho= X-Received: by 2002:a17:90b:3a0c:b0:2ea:8aac:6ac1 with SMTP id 98e67ed59e1d1-2f782d1c5bbmr18106232a91.15.1737355316120; Sun, 19 Jan 2025 22:41:56 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Amul Sul Date: Mon, 20 Jan 2025 12:11:18 +0530 X-Gm-Features: AbW1kvYKNz9_QvVAubP7bo5U9OSKoMQzSqCQY_ahdQbi_TZ0QqjATWyCpxTHO8o Message-ID: Subject: Re: Bug in detaching a partition with a foreign key. To: Sami Imseih Cc: PostgreSQL-development Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, Jan 18, 2025 at 2:14=E2=80=AFAM Sami Imseih w= rote: > > This is a bug indeed. I tried your patch, but it ends up in a seg fault. > > [...] > If the relation on the parent and child constraint match, that > tells us we don't have inheritance. > So, I am thinking we should add another condition for checking > if a foreign key is inherited by checking if the parent constraint > relation is different from the child constraint relation. > > I am attaching an unpolished patch ( we need test coverage as well ) that > implements the above. All tests pass with this patch. Thanks for confirming the bug. TBH, I haven't had a chance to look into the issue in detail yet, but my understanding of the detach operation is that i= t should cut the link between the parent constraint and the constraint on the partition being detached. The trial patch I posted was meant to prevent cutting the link between the partition's constraint and the constraint that inherits it. Your patch seems to achieve the same, AFAIUC, but I'm not sur= e I like the way it's doing, nor the trial patch I posted. A crash is certainly possible with that patch, but it would be helpful if you could provide more context -- such as crash detail and/or a test case. Regards, Amul