| From: | Corey Huinker <corey(dot)huinker(at)gmail(dot)com> |
|---|---|
| To: | jian he <jian(dot)universality(at)gmail(dot)com> |
| Cc: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, Vik Fearing <vik(at)postgresfriends(dot)org>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: implement CAST(expr AS type FORMAT 'template') |
| Date: | 2026-03-31 17:47:43 |
| Message-ID: | CADkLM=dGxwVCp3y8=LU+8hQUPw61JELx2jh02i729YCex8UqWg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, Mar 31, 2026 at 3:48 AM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
> On Tue, Mar 31, 2026 at 6:18 AM Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
> 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tomas Vondra | 2026-03-31 18:03:02 | Re: EXPLAIN: showing ReadStream / prefetch stats |
| Previous Message | Nathan Bossart | 2026-03-31 17:45:55 | Re: Fixes inconsistent behavior in vacuum when it processes multiple relations |