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.96) (envelope-from ) id 1wSWX1-003EdV-1O for pgsql-hackers@arkaria.postgresql.org; Thu, 28 May 2026 08:55:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wSWWx-00BN3t-36 for pgsql-hackers@arkaria.postgresql.org; Thu, 28 May 2026 08:55:56 +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.96) (envelope-from ) id 1wSWWx-00BN3k-0v for pgsql-hackers@lists.postgresql.org; Thu, 28 May 2026 08:55:56 +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.98.2) (envelope-from ) id 1wSWWv-00000001pXe-0CMj for pgsql-hackers@lists.postgresql.org; Thu, 28 May 2026 08:55:55 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id A7BF21400107; Thu, 28 May 2026 04:55:49 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Thu, 28 May 2026 04:55:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kurilemu.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to; s=fm2; t=1779958549; x= 1780044949; bh=wXAkEQMcLEVM9TsgEO6ol1Mz1JlGnuHD5CTpWGvemtA=; b=B IZsOqaUcoe6HNr1CShkQv6ZAMTFy5flaFg5CEx/MVHjFJyErAjckyeev69Jtw0MM 8H7gnSSjOGn5IkM7yF67IAf22XJTdAhp3Rg/hTyhA0VHKKKWT6EeY7I8OVL41vrz vjGhMW4uZWUEE/TTwv3OsijybmaH4kzrFy360ZyQzc2j22gMS560b68Fk6uQGenZ 6yN0tqUs3spgxnAcPtQhu+ZFFcTpQRMDM7Y1B+nFIYiYoIqBkFExnZNjPi2B0CEQ m8UoMiEimCmYGM8LwkSR6Br/ZoW6zzh1F2iZHDHF5dReXUpbHRQ/Eq+SDqbldgWR ie9iXzRHgYQ2K3RuYaVXA== 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-sender :x-me-sender:x-sasl-enc; s=fm3; t=1779958549; x=1780044949; bh=w XAkEQMcLEVM9TsgEO6ol1Mz1JlGnuHD5CTpWGvemtA=; b=B6Pvy8ufFRdJR8zn3 Cz3HZC/VazTrAaGDuUp6+DKvGi3U+OR5R5uDoXV8iKdibGkWVo14J+fCmDt0F0ao OUcsQ4rxshRjQDOc03QzbBJ4wF2wzfsHuIQ295CCWXK8EZ54DsnB7ZLFxp01E7zK L0ol9Wet+yHjDhQUVDH/jLi/wmiLMGgL3ZhJEVjLoyssaec0G0yeXW/fNoLO2ko6 TB8Nk+DCZ1eZOLQwbWS6HlAIXuIEWwpXsoj54e42+sXXseJlYmBK1ANeeSw5Y6uk iE498dsWLJyUttAGf6VLS/Nb+wAqsoEsB99rFcxHFfwDG/KjRMTFfNEVlLMH6Kli PaipQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFU4rKHxq41TaWd0y5Oje0QFgi3HKXmDZjc0o4+mxdtjaCPejf7V0WvpK/uh9c+D1 eYs+KALzFekuvTuY26vzZjWQhzclGDvCI+j88C8RlXhB9GzJrHW9+iKetXSZkZwaNqPAFj mkdBkcgduRC3apu4ODfqr3My87Sn2FQV2dyvQt6wsD/g4dwF1I8j91GBh6p3OpMceVtlzP Qfud618g3pdoi/DzBtxH8P7SdjcFOXQ8OEn2DHmhLNQzcUVzaXDIlybrPV9PDNMnwd9Vm5 IYBNSQq9werv3s8eIrsGaDJZudZjIPtJj+GFW3VW5ujx0Pgy4Y1fAkDWF1PwsY0hqSmStC iIX00bEuc2GuyWYRCIZMm3dTI2sxTLwo1dlsDIoZ9ZSZfKjS+xJSb3CdhkP26lUqWA56Pd GiicPduD1/7RjBQw10NGFKCEhT0QIyhl2VoN580SqliHKkh1NqCfNh2LeYvrNwQ44XG+wy Cn4euaN9z3sBL81Y8aldFs+3yBWCQuyiR5tJnVic3ZoST2h2X05RZzaacdMAbySlrcwsNa E736tp1Yp1GJ9TX6Fdovg+fWjA/6VnBE7ZRUI7OJntnUY7Q4rRHqayxLr1gpUxW0npRLnp IV7/iOE1sYVSJQBpZn0/shQhLmn9oEDc8ebxn7C8VLRMINC5BD0D5R6hXc3w X-ME-Proxy: Feedback-ID: ie3de48e3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 28 May 2026 04:55:48 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kurilemu.de; s=schmee; t=1779958545; bh=r/ItWwgcCNcFE77bgAdyDvpkmRQmvSKJeCCw5cDOf48=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=Xa97YePadGKVpxCVQu/oT7JQ5p8v1d+lcFYmo63ojEn+7H4ndwhYzLKM+8+sBpiSV Ze017w8b1zSLBzeU0CFozak4lE9KoPBYnh+d176jFKbS5pgWVlN98j/fIoPROxT+dr AhTOCzu1RvjktDhtCmXZ+Lr1duu4knwJ5WWG74RoHThGWAmXGLo9254StvBIuGWZw9 1JYevQdIyVsci4i+4FMs8ExRJZDuQSYL9BCBgTvO4ZStcUbZc8PutYp8LekTGO+vvA sITW3aHLw23s4YjZHWDetQQP2xuckH32nrAGRURgAW5Cne/PyY4DaxnNz6bAhUqYHz 7krxs4Dw7V5Hg== Received: by ida.kurilemu.internal (Postfix, from userid 1000) id 1292FB00631; Thu, 28 May 2026 10:55:45 +0200 (CEST) Date: Thu, 28 May 2026 10:55:45 +0200 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: jian he Cc: Chao Li , "L. pgsql-hackers" , Andrew Dunstan Subject: Re: Fix bug of CHECK constraint enforceability recursion Message-ID: 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 2026-May-28, jian he wrote: > CREATE TABLE p1 (a int CONSTRAINT c CHECK (a > 0) ENFORCED); > CREATE TABLE p2 (a int CONSTRAINT c CHECK (a > 0) ENFORCED); > CREATE TABLE ch () INHERITS (p1, p2); > ALTER TABLE p1 ALTER CONSTRAINT c NOT ENFORCED; > > The v2 patch marks check constraint c on table ch as ENFORCED, which > seems to contradict the documentation's wording: I think what v2 is doing in this case is correct. The child's constraint must preserve whatever the strictest of the inherited constraints status is. In this case, because the constraint on p2 remains ENFORCED, then it must remain ENFORCED in the child as well. Changing it to NOT ENFORCED after the ALTER TABLE would be wrong. > https://www.postgresql.org/docs/devel/ddl-inherit.html > <<>> > ALTER TABLE will propagate any changes in column data definitions and check > constraints down the inheritance hierarchy. Again, dropping columns that are > depended on by other tables is only possible when using the CASCADE option. > ALTER TABLE follows the same rules for duplicate column merging and rejection > that apply during CREATE TABLE > <<>> I think this text is a bit vague in that it isn't really considering multiple inheritance -- it appears to be written with the perspective of each child table having a single parent. It may be a bit obsolete also; it talks about "check constraints" but we also allow not-null constraints to have these kind of properties as well (which we didn't when this was written). > The wording (https://www.postgresql.org/docs/devel/ddl-inherit.html) > below also discourages directly altering check constraints on child tables. > <<>> > A parent table cannot be dropped while any of its children remain. Neither can > columns or check constraints of child tables be dropped or altered if they are > inherited from any parent tables. If you wish to remove a table and all of its > descendants, one easy way is to drop the parent table with the CASCADE option > (see Section 5.17). > <<>> Hmm, I think this text is borderline obsolete, in the sense that we know allow changing some properties of some constraints in child tables. I'm not really sure to what extent it is useful to make it more explicit about that. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "You're _really_ hosed if the person doing the hiring doesn't understand relational systems: you end up with a whole raft of programmers, none of whom has had a Date with the clue stick." (Andrew Sullivan) https://postgr.es/m/20050809113420.GD2768@phlogiston.dyndns.org