Re: ERROR: failed to find conversion function from unknown to text

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ERROR: failed to find conversion function from unknown to text
Date: 2026-01-29 03:53:39
Message-ID: CACJufxGEpQiMUOFcw5G67sNqgdyXxB7h-mpA_6neqNRf4qov=g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jan 29, 2026 at 9:24 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Is there a good reason why that shouldn't be an error?

at that time, i want
select cast('a'::text as unknown);

behave the same as

select cast('a' as unknown);

To make it an error, meaning it's not possible to coerce to the unknown type.
We can do it in the function find_coercion_pathway, just
after the ``if (sourceTypeId == targetTypeId)`` check:

if (targetTypeId == UNKNOWNOID)
return COERCION_PATH_NONE;

it's also doable in the function can_coerce_type,
right after the ``if (inputTypeId == UNKNOWNOID)``:

if (targetTypeId == UNKNOWNOID)
return false;

--
jian
https://www.enterprisedb.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2026-01-29 04:58:26 Re: pg_plan_advice
Previous Message Srirama Kucherlapati 2026-01-29 03:43:06 RE: AIX support