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 1st8tH-00DsrT-S2 for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Sep 2024 16:59:56 +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 1st8tH-00AocJ-7z for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Sep 2024 16:59:55 +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 1st8tG-00Aoc4-JF for pgsql-hackers@lists.postgresql.org; Tue, 24 Sep 2024 16:59:54 +0000 Received: from fout-a6-smtp.messagingengine.com ([103.168.172.149]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1st8tC-000sBO-E4 for pgsql-hackers@lists.postgresql.org; Tue, 24 Sep 2024 16:59:54 +0000 Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id 5EC27138026F; Tue, 24 Sep 2024 12:59:49 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Tue, 24 Sep 2024 12:59:49 -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=fm2; t=1727197189; x= 1727283589; bh=jjN2aeQcHoc9TJQ5sDJ5J843ENjRzb4g+Nqo+rx/4rY=; b=m Rccx+C8F0Jb6tYaobbfdu1Z1ZUph1Gpc/bmXJ4bNDsU9EJW3tFsW/0nmJ+ZF3NIG 10uE1FUGE1jnaxXr4MvyYk6c7J4rswiZB7fpjhlt2j3GRYsdi1N7QqhHeX+VD+ur NJVKpRWQglCdwbqI8EyCHP9svaNjsOb0dy9QO+3ykrXqzdZGT08T451wgDNOhdi/ oVN/qoO0sWNqz5ELeUI5v+CHCuftBkemaW5O3O/hbvK52rBozCahVp8TdnMJC6uA oRGB0HSc8d7P18BAayykTnVFUaJgbP7Zq3op2JD9mYOL+s2PNpA2ZacgyjaPvU07 LJkz/ab2prwD5o69fdUfw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddtfedggeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeen ucfhrhhomheptehlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhh drnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepvdektdffudfftdffffehfffh jeejhffgieeuueekjeekfffgudffhfduffffueevnecuffhomhgrihhnpegvnhhtvghrph hrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgr ihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgpdhnsggprh gtphhtthhopeefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehjihgrnhdruhhn ihhvvghrshgrlhhithihsehgmhgrihhlrdgtohhmpdhrtghpthhtohepthhnughrfigrnh hgsehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhi shhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 24 Sep 2024 12:59:48 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1727197186; bh=Nh4W0opM2PiWbyEVZnZrynhk82/agdUIezp4rHaWQrQ=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=h94DFP89pguDYJNfDE6/uDYvnly+T045M4YkNUAG1bvSv2AFHI9X1wVYOHHKo6lJQ PIynAvmBiXcH5nbBfgeXUi9eVfm8vCiaOCq5yEWQspBk4fgQ+ZsuNsvPUfI7WLkJd0 Ew9FSWUNJi7GFRLKGl0NM0auikaUFwPJddnNAz6jjXnOd7cuqriS8lpeCzptM9wL0/ aFYyFnsY/Xxe7r4+pvHr58rYHECWqNjnmNSeExSalm2YwBl9pxv8yvlJsTGiMj3JNl ZoCdhULYJQB/tZgWip0UVho6RDSrWhI1arZQz72NYBXhjX/EH5/wrZA+5c639in7DU Pm6Oc5v2tlQOA== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 3C4EFD9; Tue, 24 Sep 2024 18:59:46 +0200 (CEST) Date: Tue, 24 Sep 2024 18:59:46 +0200 From: Alvaro Herrera To: jian he Cc: Tender Wang , Pg Hackers Subject: Re: not null constraints, again Message-ID: <202409241659.p77vki2o6wbp@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-Sep-24, jian he wrote: > sql-createtable.html > SECTION: LIKE source_table [ like_option ... ] > INCLUDING CONSTRAINTS > CHECK constraints will be copied. No distinction is made between > column constraints and table constraints. Not-null constraints are > always copied to the new table. > > drop table if exists t, t_1,ssa; > create table t(a int, b int, not null a no inherit); > create table ssa (like t INCLUDING all); > > Here create table like won't include no inherit not-null constraint, > seems to conflict with the doc? Hmm, actually I think this is a bug, because if you have CHECK constraint with NO INHERIT, it will be copied: create table t (a int check (a > 0) no inherit); create table ssa (like t including constraints); 55490 18devel 141626=# \d+ ssa Tabla «public.ssa» Columna │ Tipo │ Ordenamiento │ Nulable │ Por omisión │ Almacenamiento> ─────────┼─────────┼──────────────┼─────────┼─────────────┼───────────────> a │ integer │ │ │ │ plain > Restricciones CHECK: "t_a_check" CHECK (a > 0) NO INHERIT Método de acceso: heap It seems that NOT NULL constraint should behave the same as CHECK constraints in this regard, i.e., we should not heed NO INHERIT in this case. I have made these changes and added some tests, and will be posting a v5 shortly. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ really, I see PHP as like a strange amalgamation of C, Perl, Shell inflex: you know that "amalgam" means "mixture with mercury", more or less, right? i.e., "deadly poison"