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 1vNNQe-00105q-0r for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Nov 2025 03:39:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vNNPc-00GKpN-1s for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Nov 2025 03:38:48 +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 1vNNPc-00GKpE-0d for pgsql-hackers@lists.postgresql.org; Mon, 24 Nov 2025 03:38:48 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vNNPZ-0018Tu-2E for pgsql-hackers@lists.postgresql.org; Mon, 24 Nov 2025 03:38:47 +0000 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-343ea89896eso4020012a91.2 for ; Sun, 23 Nov 2025 19:38:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763955525; x=1764560325; 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=Gv+gFB3oRbghxpQQ96NpEo9z02WbH7y+hwTnSSEleuk=; b=mSnzGwo1s5LKlUEP/1XmrWxq2ENZVPezbCS/+r/B1oYh9lTy4qYFtaEs4T6ZqFwP4K 5aURueUWobvtJVG9u0CLzaEDpeEWuwSxOaHo6s44mI6/MT1ekz9FDTuNmMc7PHgss9HM 0wHyLnjuVNscnImj3ikEkAt+7ADEyIvNR/05cdxKWgvFpRknRbXMW23iSq8V7fRFBNPt iDc295+CcMAZHlSTWeihzfTCh2O04zg94YdU5dNBPHkSFfTOGOitEE9hc8Owso8tkXJQ d5labu+0WSvos4oWJB+grzDEpk4vWzZQP+I1yzX1CU6s9eZ00mCGED8fAF+OegNCgpkX tmsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763955525; x=1764560325; 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=Gv+gFB3oRbghxpQQ96NpEo9z02WbH7y+hwTnSSEleuk=; b=DaZQa1Xi7BuW9oOzaler1hLhYfUij9StU0iagICnboBslh3I8UAz8+7K3gIT+OxrEv wqiG1GBBdk6jt6u3KZbi25T0ryASKOK3oAgTV1VTSoBaR6wVHH0owL60OW00bD7J16fx 6ZtQHvhT0XeIYTdHP/TCCZibMqBHvmAeIOD3wJF6nincjci/0l3bL5p8jsh3voMONwn9 YJGlX38IHOSwammMHEPm/ErmQZ0cQE2to4ZvADeU3IkFTP5NuQfRGBq5qKUDMIAgT1R+ 4fd2t3E7zyq5dLIZHi3dI9RhOxLNtytDsO2e4JnSZumKDl+CSUJerl5QIJu+Eq24uWGH 3smw== X-Forwarded-Encrypted: i=1; AJvYcCUIwtLeTLhVIw9MdW+7XXvATL99GJHH/Ni2wt5FE0ty938eW/nb2TIIEn7Od9oX5q+r34Jj79AHVipU+wX+@lists.postgresql.org X-Gm-Message-State: AOJu0Yxe32apPlGyxvNVqqZqFZLlwzToFT+pksY6gKW1/0jMNDo+I9dh kC1C9saIHkrWereodAjooI4EY4YKGh6HxJWGaBm+uosL+UV4Vhf/wNyevPVk7O1pcTTyQA6iLrV /s9IQKLePxewx+0BSil/D7TydVqZgq2o= X-Gm-Gg: ASbGncsMxWmJg1jCo6mJSxLY6KwUFQfLV9yVbeO1ZjolGxzLivJu8ZkbRnUwv9EWoX7 Vuvp+1IBzIRKNaRUHhjn7MC1n9oXqcOZFxqmVW1pM1/sX11vDn8JjCv5qq0w5MDHzr1eSg2mzKf eJ+BNAdQQ43aWitgCOYCFQQWhCyeqlEeSthqA3maOVKgH764shaAj/HSIHJRcDbFKhCXmYtJIgJ bbOQbw0qDTdzRz9Vc23c5wzA/8zG1pHUVUZighu8hl3BzXKdfsW+vb3i39C8TPv8D59jb+v X-Google-Smtp-Source: AGHT+IEWLhM2SRWcbkdSONVCH3eyBORZiMI2JxaUYUnoD7jRQaubWAqietoL5tasKr0xDzJcImM1Y39S0jE8NGfLszw= X-Received: by 2002:a17:90b:4906:b0:340:f05a:3ebd with SMTP id 98e67ed59e1d1-34733f23548mr7488032a91.28.1763955525014; Sun, 23 Nov 2025 19:38:45 -0800 (PST) MIME-Version: 1.0 References: <04afcd1f-ed7d-4c0a-add1-50e3719ccbf9@postgresfriends.org> <762ae707-7fdc-43d8-a77a-3a10d12ce21d@postgresfriends.org> In-Reply-To: From: Amul Sul Date: Mon, 24 Nov 2025 09:08:08 +0530 X-Gm-Features: AWmQ_bmaRZiiAuAtHKejkanVbw1DRl-a0O63vb_2xiUYmRggWJ6IPqSChBlyFQQ Message-ID: Subject: Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions To: jian he Cc: Corey Huinker , 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 Fri, Nov 21, 2025 at 2:11=E2=80=AFPM jian he wrote: > > On Mon, Nov 17, 2025 at 9:43=E2=80=AFPM Amul Sul wrot= e: > > > > 10-0004: > > > > +/* error safe version of textToQualifiedNameList */ > > +List * > > +textToQualifiedNameListSafe(text *textval, Node *escontext) > > > > If I am not mistaken, it looks like an exact copy of > > textToQualifiedNameList(). I think you can simply keep only > > textToQualifiedNameListSafe() and call that from > > textToQualifiedNameList() with a NULL value for escontext. This way, > > all errsave() or ereturn() calls will behave like ereport(). > > > > The same logic applies to RangeVarGetRelidExtendedSafe() and > > makeRangeVarFromNameListSafe. These can be called from > > RangeVarGetRelidExtended() and makeRangeVarFromNameList(), > > respectively. > > -- > > > > hi. > > List * > textToQualifiedNameList(text *textval) > { > List *namelist; > rawname =3D text_to_cstring(textval); > if (!SplitIdentifierString(rawname, '.', &namelist)) > ereport(ERROR, > (errcode(ERRCODE_INVALID_NAME), > errmsg("invalid name syntax"))); > } > > I don=E2=80=99t see any way to pass the escontext (ErrorSaveContext) with= out changing > the textToQualifiedNameList function signature. > > There are around 30 occurrences of textToQualifiedNameList. > changing the function textToQualifiedNameList signature is invasive, > so I tend to avoid it. > I think it's easier to just duplicate textToQualifiedNameList > than changing the function textToQualifiedNameList signature. > > Am I missing something? > The change I was suggesting will be as below: --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -2684,6 +2684,13 @@ name_text(PG_FUNCTION_ARGS) */ List * textToQualifiedNameList(text *textval) +{ + textToQualifiedNameListSafe(textval, NULL); +} + +/* error safe version of textToQualifiedNameList */ +List * +textToQualifiedNameListSafe(text *textval, Node *escontext) { char *rawname; List *result =3D NIL; We must try to avoid duplication whenever possible, as any bug fixes or enhancements would need to be copied to multiple places, which is often overlooked. Regards, Amul