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 1s2k6h-005gD5-14 for pgsql-hackers@arkaria.postgresql.org; Fri, 03 May 2024 04:01:10 +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 1s2k5e-005cL2-I9 for pgsql-hackers@arkaria.postgresql.org; Fri, 03 May 2024 04:00:07 +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 1s2k5e-005cKu-6k for pgsql-hackers@lists.postgresql.org; Fri, 03 May 2024 04:00:07 +0000 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s2k5c-001HV3-0I for pgsql-hackers@lists.postgresql.org; Fri, 03 May 2024 04:00:06 +0000 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2e0b2ddc5d1so56657021fa.3 for ; Thu, 02 May 2024 21:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714708803; x=1715313603; darn=lists.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=VuquCJ2VNF+fNj6PvxHxgszPISvdMFXNBSGOLl/Syus=; b=X9ArOGK8/01YbQWy8FVUuBJH452FWbNsS3wAUCe0HHErCJ3udKMW+rFbYf1Xe+DAq4 kHYotmiZ6oat14angYWmQrXRNU3/HBOv01aIyyIkriP1aDtQ64psjR0qU1YTxCNqkOGz 7UG0L8Dukn3DlgK959sc7zU41oC3hj6KFHRXjNn0uKpHPv/8Q+zdBiPTd7igtSMHlbJN RZ80J9YsXbo/8baGedc/SSzEWOqO27Zl9IOps2+Y43Y4SQIkQgHc2LjTUoTOZVSKSzJn Qd9rxkBTYaiQA6IzturZ4L0EbvjyN0Idifah7dJjovsHhlj3VLu+9a9rI6SGwaj2SJO3 TcnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714708803; x=1715313603; 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=VuquCJ2VNF+fNj6PvxHxgszPISvdMFXNBSGOLl/Syus=; b=hfUrdfbIhnTEH8KFXpE6A157U1YZs8oswfiiq7afHU9iDLvNNB+YA9KpZmeEv+9QWH vHjgOMQ72WB3MOfG3BOyfXF07xd+xnDq80KDrwx+eA3qs+CweqZewBo7Aocbx35S6MtY BLGy/9RPdDVzoY+Ohfqq9ORwTwevy5lFF4r6js7XMV9owMcGF97X3jYBBbQH+U1CgQA7 6zWiSNGY4LgwcQ87HqK3FOvy1V8RfAkyXIv2U76t+Q9qm+FZoSa0iPfVZ1v/F58rivIB 8Ayp1YMIjiiforJXGfCOEFJi2sSVfdnocUGNWc7w5R2DKgc3uT626z/+SyRbmwEiCR2d +HfQ== X-Forwarded-Encrypted: i=1; AJvYcCU25HidYq76nchNW31P10De++48zrgqj86Kc1unmJpFS8+nGTxwm0LPgXMlFSlyB/xecasTGe3ORH9NhU1lARsAfgxx0sscuI5Qn3BzQEUdO1Ky X-Gm-Message-State: AOJu0YzWavNSuLSQEVpMLlhGD/oIMbAsxqWqksPKEpsb+ZiRxzip5jlB 3vLlu7wiY1k9emw8zZOBC3pop2y5ttc/LpO5IKZ6la2zIthYQXwQ X-Google-Smtp-Source: AGHT+IGYnDAC43HdfdXpXViVRN71isHjnzsVI3XzV1yJtPBEoEfmwgDWNx5ohV5wl44BO9J0r06XxA== X-Received: by 2002:a2e:6a17:0:b0:2df:6cb8:c92f with SMTP id f23-20020a2e6a17000000b002df6cb8c92fmr860388ljc.23.1714708802566; Thu, 02 May 2024 21:00:02 -0700 (PDT) Received: from [1.0.0.7] ([178.155.23.194]) by smtp.gmail.com with ESMTPSA id x23-20020a05651c105700b002dffa4aef20sm399378ljm.2.2024.05.02.21.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 May 2024 21:00:02 -0700 (PDT) Message-ID: <7d0f1fea-0f1a-2c9f-9b02-867b73abee78@gmail.com> Date: Fri, 3 May 2024 07: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: cataloguing NOT NULL constraints Content-Language: en-US To: Alvaro Herrera Cc: Dean Rasheed , Andrew Bille , Peter Eisentraut , Robert Haas , pgsql-hackers@lists.postgresql.org References: <202405021621.ftmuhmfg7f2j@alvherre.pgsql> From: Alexander Lakhin In-Reply-To: <202405021621.ftmuhmfg7f2j@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 02.05.2024 19:21, Alvaro Herrera wrote: > Now, you could claim that the standard doesn't mention > INCLUDING/EXCLUDING CONSTRAINTS, therefore since we have come up with > its definition then we should make it affect not-null constraints. > However, there's also this note: > > NOTE 520 — s, except for NOT NULL, are not included in > CDi; s are effectively transformed to constraint definition>s and are thereby also excluded. > > which is explicitly saying that not-null constraints are treated > differently; in essence, with INCLUDING CONSTRAINTS we choose to affect > the constraints that the standard says to ignore. Thank you for very detailed and convincing explanation! Now I see what the last sentence here (from [1]) means: 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._ (I hadn't paid enough attention to it, because this exact paragraph is also presented in previous versions...) [1] https://www.postgresql.org/docs/devel/sql-createtable.html Best regards, Alexander