On Tue, Mar 31, 2026 at 3:48 AM jian he <[email protected]> wrote:

> On Tue, Mar 31, 2026 at 6:18 AM Zsolt Parragi <[email protected]>
> wrote:
> >
> > v6 is better, but I found a few more questions:
> >
> > +select pg_get_viewdef('tcast_v1', true);
> > +                                       pg_get_viewdef
> >
> +--------------------------------------------------------------------------------------------
> > +  SELECT CAST( col1 AS date FORMAT 'YYYY-MM-DD'::text) AS to_date,
> >                      +
> > Is that space after "CAST(" intentional?
> >
> I have removed this white spce.
>
> > + format = coerce_to_target_type(pstate, fmt,
> > +    exprType(fmt), TEXTOID,
> > +    exprTypmod(fmt),
> > +    ccontext, cformat,
> > +    exprLocation(fmt));
> >
> > Is exprTypmod(fmt) correct, shouldn't it use -1?
> >
> yes. it should be -1.
>
> > This one also shows a not so userfriendly error:
> >
> > postgres=# SELECT CAST('hello' AS name FORMAT 'test') ;
> >
> > SELECT CAST('hello' AS bpchar FORMAT 'test') ;
>
> now:
> SELECT CAST('hello' AS name FORMAT 'test') ;
> ERROR:  cannot cast type text to name using formatted template
>
> SELECT CAST('hello' AS bpchar FORMAT 'test') ;
> ERROR:  cannot cast type text to character while using a format template
> LINE 1: SELECT CAST('hello' AS bpchar FORMAT 'test') ;
>                ^
> DETAIL:  binary coercible type cast is not supported while using a
> format template
>
> type Text to type name is not binary coercible, see outpout of:
>
> select *, castfunc::regproc from pg_cast
> where castsource = 'text'::regtype and casttarget = 'name'::regtype;
>
>
>
> --
> jian
> https://www.enterprisedb.com/


Everything's passing, moving the tests out of citext, etc into cast.sql is
good.

I think the next step it to bring each TODO and FIXME into the thread, and
explain the factors that prevent you from being certain about what to do in
those situations.

Reply via email to