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 1w7CNk-0053jK-16 for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 13:10:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7CNh-003NQr-1l for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 13:10:13 +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.96) (envelope-from ) id 1w7CNh-003NQi-0B for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2026 13:10:13 +0000 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w7CNf-00000001o4M-2kXm for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2026 13:10:12 +0000 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-c757a9251faso1718844a12.1 for ; Mon, 30 Mar 2026 06:10:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774876210; cv=none; d=google.com; s=arc-20240605; b=TznNaF4o2fk8EZdZDTVmVX7ImY4mEGtRk3yIfbUX8otTHRlBlUJNpIZXL58lFWzIs9 nzFPBJBz3vRZWZ4UiCoz0aYkYGZOT0g10Dny0K+EeR4wz02GxqeocvvlCO0ZUmL8kIRz GnSc5IBU3skBMWwlVnwl3T4fQANfYYIvwZrNzKCptxfHLS0tiGi3wTLE7v0hJvQQelAF uyOKPwkLpS18+JUbNzDzwbspzi+HsHle0WxU9bv0+tfDOSrkbPjxePa8rBgVw6ooJqIN FqsB/gBo4nTGVbCk00Rny6i6uo19o882h/eo/v8jC0vWq6gaFI87J5cnC7M+LvOUisvP NkwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=XiGns+tMc3SPT8fuPkqGtGnlm9IHqnXLsG6bNmz7gVo=; fh=2gbatfS32R3Zvd44rAxgPa5Sqti9OeZD+Yvr1D4vHb0=; b=BxP8a/QAnU+eyhBNl1nPwfOdisC7dGqrgdADn64AW+590fXQvdVdkPrDQyjE6Nw6tD 99J9F8IE1Nz4Zv6ro18375qQ4+k3FwCInCO97nIzhmJFBsFjlDJL3IGF5Yspzh8hAxJR SPYRCYAO2297CkzKWqQm6a/KkRyuiWEEINF3C0SBZE3MUY6Jvs4LZqXmykLZb1WDqW0s h5UIg3IyN59YBtyEQO7n5VCij5XoArBe9/MtJylBlnlpUbelcUbPnTH2YO4z6HleF48B xKANmOPeAhArtYp6AgLWMUMALs6d3SMxJTlbiPCcqVfFWKXvl0NquEEsDbc18BPYNKLw oogQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774876210; x=1775481010; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=XiGns+tMc3SPT8fuPkqGtGnlm9IHqnXLsG6bNmz7gVo=; b=d9JvI/W3Gx5VrKxfq60GJgoekp1bgzN+dHvHdi0r6ruHjwnAtPCFzKadxbPwaBTc4I UwOoiPC0WLXJjXCvFCb31OQ6abSQo1MoxX5bEe2eQ7tp3RN4Lh3NlrWCF7jne84nxkDQ /G1bKR+NZZxeADP44n+3YlgO9znjKevDhX4K2VUbXaFucc78l20+sGiaX+2eSBOyjAXa f35kY5UQUk0ijh1Lui6+iYuySWzLnJUVljFyco8X6zi1OIEHFhC2d2858+SRn5Yjr9U6 kmLdg07nOhOqIsBZa35xGzfj1Md14kNHY7H0RMmO4kbwZMvoDNci5/fIMLLix6p4QvNS XyTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774876210; x=1775481010; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=XiGns+tMc3SPT8fuPkqGtGnlm9IHqnXLsG6bNmz7gVo=; b=MmKgdTcI6Ud3IlehtP/9CsBgCqJXH2p/A8SIp5rXYC/afWfSch5xpVthHCDoYGX8os PSPomBLglWwOyyov1lvDB2sxLJe9Z09rPYal1AjAbPkGgzCXIgmKZeYCIVZSm16RKY31 Vq+J9WOCefltsXIe3a9Ax0yNIwCpqVVaV2abI5V2Rfd1KVDSoQ456Lz1li36Jt1TMnpR 45E5ZMm4L2bmUFMlkG9qvBxwwzRU9DF4jZPh4NRZ7dq+kbYGFwKGAFBSGOlHWsAti7jj QpLGrxvcdiSV/OfkH7/OaM6RVWfOyGstjukjmExQPufdPHUzEZKxje+Do6Brhoq/S3++ IVug== X-Forwarded-Encrypted: i=1; AJvYcCUWzMiuYx3Rij8wIeh3XJrvlKs9up+0q6XRgoH4/fd41Ypfzf6lzq0M7QkDbIIXPkQojAFpURFE4/3zJLC0@lists.postgresql.org X-Gm-Message-State: AOJu0Yx85MCZesb4BHGWJ44apP/Gey4jpXHiyn32LJqdEyxmjhGEIoKp dMW1ZdLO7bf3l+7UItHQPDi5v9QENSFMkJCeMO2cBpgKMOfL825/7Qmk4B9qE4N30VYQunJbH/d Ua7BKIwO08hX+O0kMEijvlWj69suUGrk= X-Gm-Gg: ATEYQzzFzZdvXG6cscwlqC5s/19PWuRazHnen1V8QjCxJe7gFuPyfe6xTMcIyR0MtVG EP8aulzLK0XOFw40DXM79A5MhIWGBFxS1m4gx00apkWjNelT8gnTozxweaUxo3RQLHnj1p3+OFF GH0gyRGsRMSKICdolOozcLOOzQyPdEnEH+qyHoOQliYOa9SHDkuqqsL52I8Q2YHk0nykymDrOUo Guh14ifB986WeZhEvfp85scI8Mw/SjdHVDq4iTwDCTJXLDbqdgR1j7repFrAALT0dXjBUpJp6Tc PUijHBAxFZZoKnNcB/4L X-Received: by 2002:a05:6a21:e098:b0:39d:b092:7725 with SMTP id adf61e73a8af0-39db092f57bmr4373782637.53.1774876210288; Mon, 30 Mar 2026 06:10:10 -0700 (PDT) MIME-Version: 1.0 References: <5ae9578e-f25e-49c5-97ab-ad27bc2050b5@eisentraut.org> <5221f892-e1d5-4943-a3dc-5c9c7bdf4924@eisentraut.org> In-Reply-To: <5221f892-e1d5-4943-a3dc-5c9c7bdf4924@eisentraut.org> From: Amul Sul Date: Mon, 30 Mar 2026 18:39:32 +0530 X-Gm-Features: AQROBzB6Fa7OPlcjcqkW2BmooK-Qse_CPmCgpnG2RjqB6VphxI0f7t6Xna624mw Message-ID: Subject: Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions To: Peter Eisentraut Cc: jian he , Corey Huinker , Kirill Reshke , Vik Fearing , Isaac Morland , pgsql-hackers@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Mar 30, 2026 at 4:57=E2=80=AFPM Peter Eisentraut wrote: > > From the v25 I have committed everything except 0001 and 0009. I will > continue reviewing the rest. > I=E2=80=99ve had a glance over the remaining patches; here are a few commen= ts: V25-0001: - if (relation->schemaname) + if (escontext =3D=3D NULL) ereport(elevel, - (errcode(ERRCODE_UNDEFINED_TABLE), - errmsg("relation \"%s.%s\" does not exist", - relation->schemaname, relation->relname))); + errcode(ERRCODE_LOCK_NOT_AVAILABLE), + relation->schemaname ? + errmsg("relation \"%s.%s\" does not exist", + relation->schemaname, relation->relname) : + errmsg("relation \"%s\" does not exist", + relation->relname)); else - ereport(elevel, - (errcode(ERRCODE_UNDEFINED_TABLE), - errmsg("relation \"%s\" does not exist", - relation->relname))); + ereturn(escontext, InvalidOid, + errcode(ERRCODE_LOCK_NOT_AVAILABLE), + relation->schemaname ? + errmsg("relation \"%s.%s\" does not exist", + relation->schemaname, relation->relname) : + errmsg("relation \"%s\" does not exist", + relation->relname)); } The error code changed here -- was this intentional? -- v25-0009 : +SELECT CAST('abc'::bpchar AS citext DEFAULT NULL ON CONVERSION ERROR); -- = error +ERROR: cannot cast type character to citext when DEFAULT expression is specified in CAST ... ON CONVERSION ERROR +LINE 1: SELECT CAST('abc'::bpchar AS citext DEFAULT NULL ON CONVERSI... + ^ +HINT: Safe type cast for user-defined types are not yet supported. "Should the HINT be this DETAIL? I believe a hint should provide guidance for the user to handle the error, but here the user cannot do anything with the given information. -- /* Generic macro for applying evaluate_expr */ -#define ece_evaluate_expr(node) \ +#define ece_evaluate_expr(node, escontext) \ ((Node *) evaluate_expr((Expr *) (node), \ exprType((Node *) (node)), \ exprTypmod((Node *) (node)), \ - exprCollation((Node *) (node)))) + exprCollation((Node *) (node)), \ + escontext)) I think we can simply cast escontext to Node * here, instead of having the caller do it. Regards, Amul