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 1voKtd-001cDj-2M for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Feb 2026 12:25:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1voKtc-003dQw-2S for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Feb 2026 12:25:12 +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 1voKtc-003dQn-1G for pgsql-hackers@lists.postgresql.org; Fri, 06 Feb 2026 12:25:12 +0000 Received: from mail-yx1-xb135.google.com ([2607:f8b0:4864:20::b135]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1voKtZ-00000001MMH-1VNt for pgsql-hackers@lists.postgresql.org; Fri, 06 Feb 2026 12:25:11 +0000 Received: by mail-yx1-xb135.google.com with SMTP id 956f58d0204a3-64ad019bb5eso301031d50.1 for ; Fri, 06 Feb 2026 04:25:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770380708; x=1770985508; darn=lists.postgresql.org; h=in-reply-to:references:subject:cc:to:from:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=WwwQcJHEVSOIaVLAUuEi4COVXUreL67Y/pfx1LHelyo=; b=PrpkyEL8uqD9LjqeSdk1NBjhQxW7uC9HFp0YsVeEwwyzYXCluqkA5AgtNt99vzFf+J KgPrMhHIe96Ma2XxDSFIYUt86T5qoAYuNl2+BP6r8qGGmdBs4nAeHTSXFxsBsvh0cY3X 3zPmfdkRNqUd6OlS3cRQiRBhnfZLbpTMNJhkV1F/OToO1UyklDzOQk72tmHBmo0VyIF0 pc0sW8uUmgzMdNGE/Jh+jobkuuhv009Wzs/qPJUmjGU+EV+l/Hd0AXZuuFMpJv/xPbqr AJ1A+DjLYGRUarhtHyanYfkRZYLSHLx92o0XyIqeLnjITKA7bIOmhs0OxLySxV/lqkf4 wlmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770380708; x=1770985508; h=in-reply-to:references:subject:cc:to:from:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=WwwQcJHEVSOIaVLAUuEi4COVXUreL67Y/pfx1LHelyo=; b=Qp6slrmM+B+LtOE0CfD8LSTLX5K7MCVCeinv9a8URP6BKZS+5wys94QUvpT0rQ1Bgl jx4MxCu6/HAhYQaH5d4yG8osFqN6sXGLZjaYf9MU0e0stoM5BlyZ/PKsGtvsavF9bAsp utFZ++2FAWQr4I1WilV4GtGrNZzrITPhxnvLU6K/Wir8Rr+KG9+3UwjksVgzY4hsRWRe ufd4bnbaMWlw+bvd5aiyobMu6UwxvDN0ClcqVtQkG0jWljk1/Nxv8e5DEbTUij9M44LK 4XIWHmSmjSwea+Q1uvA2N84keD5mej6Ejmg9oL67NPkzolJ6bY+gTfNlLlbC6JT7TH8n IR+A== X-Forwarded-Encrypted: i=1; AJvYcCWcWJM67V2j5D9/KTAcXuxB+7mZ++CqBfu+45rYPHA2MAevRGExN4gE6TgExWhTXP6TuyrcITmO35G3gHRq@lists.postgresql.org X-Gm-Message-State: AOJu0YyMe7Vht4daMsBqS52ZgqF1MuSJagiWyo7Wvu2kFI3JP0YNGday xOBvRlqGDkuDWNIvgYD1E9CJIqMn7rSjXm+Thnki2CE3UFR6XmRWN+oC X-Gm-Gg: AZuq6aLsB/h7as0sB0tv5J/nvr4B0Ho757B+LKzSVi86lxvM7uJoJvVbBFSEuBttkz/ uJ9dn3E54Mn7gnAt81zle8OkwOm5ozxRxsnUrr12nzMS58ENljBxTW6wc5yszG3UHO+WKK0/Uh3 QA6FYGeNl8DFHh7xb8L1zftQ22gMXRe4kSRR7Vp6hGk1Or5CQCfE1RTqWyDjDmceNGIexUhPyeB /L0LbXo1+eQBtI0JvYUCyJOo+7q6WaqnukQm7tKNf4PdVXwU0xMeusOzOzb/1mxmevjPm5uRFc+ vXwCdqhl5uPNUtKY+CEPgWbpQ+YdAceucDNzABf5M8OkbWM13CcdKiCJVA2nFvogRvW9xWcWqfd S9jFK03YnzYIOOGUG69YJrlq4Qu7dLybuBtXLx1kHjDoPZO3HDo740NN6ZosPIoSnAG3k7AqsTP tOfkd20BRHwm6mdy1uSaikXDceoKP/cbw4TXMHpeGIiWef X-Received: by 2002:a05:690c:f81:b0:795:1f65:4154 with SMTP id 00721157ae682-7952ab7c6d9mr23344077b3.64.1770380707539; Fri, 06 Feb 2026 04:25:07 -0800 (PST) Received: from localhost ([2804:14d:328a:a59c:4d20:d883:f7a1:b34c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7952a06a5d2sm19355677b3.20.2026.02.06.04.25.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Feb 2026 04:25:07 -0800 (PST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 06 Feb 2026 09:25:04 -0300 Message-Id: From: "Matheus Alcantara" To: "Yugo Nagata" Cc: "Peter Eisentraut" , Subject: Re: Show expression of virtual columns in error messages X-Mailer: aerc 0.21.0 References: <7c18e854-0ddb-4670-b0c4-f2541b5edd91@eisentraut.org> <20260205114521.6fed028d8d3185663f3c4226@sraoss.co.jp> <20260206125414.8f8c5f5735aa34fb05c5cc72@sraoss.co.jp> In-Reply-To: <20260206125414.8f8c5f5735aa34fb05c5cc72@sraoss.co.jp> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri Feb 6, 2026 at 12:54 AM -03, Yugo Nagata wrote: >> >> Another possibility would be to get the actual values of "a" for exam= ple >> >> and show it on the error message, e.g: >> >>=20 >> >> ERROR: new row for relation "t" violates check constraint "t_c_c= heck" >> >> DETAIL: Failing row contains (5, 10, 5 * 2). >> > >> > That would indeed be more useful. One way to achieve this might be to >> > modify deparse_context and get_variable() so that a Var is displayed a= s its >> > actual value. >> > >> I'm not sure if I understand how modifying deparse_context_for() could >> help on this. >>=20 >> What I did was to use the expression_tree_mutator API to mutate the >> virtual column expression to replace any Var reference with the value >> into the TupleTableSlot. Please see the attached v2 version. > > I initially thought about having deparse_context_for() directly output > actual values for Var references, but that does not seem like a good > approach. Replacing Vars with Consts beforehand using > expression_tree_mutator, as you did, looks like a better solution. > > One thing I noticed is that some expressions in virtual columns (e.g., > NULL and negative integers) differ from those in normal columns, for > example in the following (null vs. NULL): > > +DETAIL: Failing row contains (null, NULLIF(NULL::integer, 0)). > > However, this seems acceptable. > Yeah, after parsing we don't have the original string representation of the parse node, so at deparse_expression() it has it's own style to deparse nodes. I don't think that it's an issue and I also think that it's accepttable.=20 > Overall, this patch looks good to me. > Thank you for reviewing the patch! -- Matheus Alcantara EDB: https://www.enterprisedb.com