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 1tpfCb-009tLI-27 for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Mar 2025 03:13:45 +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 1tpfCZ-00GSaX-Fg for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Mar 2025 03:13:43 +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 1tpfCZ-00GSZC-5l for pgsql-hackers@lists.postgresql.org; Wed, 05 Mar 2025 03:13:43 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tpfCX-0011fI-0j for pgsql-hackers@postgresql.org; Wed, 05 Mar 2025 03:13:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 5253DeDF229414; Tue, 4 Mar 2025 22:13:40 -0500 From: Tom Lane To: jian he cc: PostgreSQL-development Subject: Re: support fast default for domain with constraints In-reply-to: References: Comments: In-reply-to jian he message dated "Wed, 05 Mar 2025 10:56:42 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <229412.1741144420.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 04 Mar 2025 22:13:40 -0500 Message-ID: <229413.1741144420@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk jian he writes: > Thanks to commit aaaf9449ec6be62cb0d30ed3588dc384f56274bf[1], > ExprState.escontext (ErrorSaveContext) was added, and ExecEvalConstraint= NotNull, > ExecEvalConstraintCheck were changed to use errsave instead of hard erro= r. > Now we can use it to evaluate CoerceToDomain in a soft error way, that > is what this patch intended to do. This patch appears to summarily throw away a couple of backwards-compatibility concerns that the previous round took care to preserve: * not throwing an error if the default would fail the domain constraints, but the table is empty so there is no need to instantiate the default. * not assuming that the domain constraints are immutable. Now it's fair to question how important the second point is considering that we mostly treat domain constraints as immutable elsewhere. But I think the first point has actual practical uses --- for example, if you want to set things up so that inserts must specify that column explicitly. So I don't think it's okay to discard that behavior. Maybe we need a regression test case demonstrating that that behavior exists, to discourage people from breaking it ... regards, tom lane