Peter Geoghegan <> writes:
> Here is the single, hacky change I've made just for now to the core
> parser to quickly see if it all works as expected:

> *************** transformTypeCast(ParseState *pstate, Ty
> *** 2108,2113 ****
> --- 2108,2116 ----
>       if (location < 0)
>               location = tc->typeName->location;

> +     if (IsA(expr, Const))
> +             location = ((Const*)expr)->location;
> +
>       result = coerce_to_target_type(pstate, expr, inputType,
>                                                                  targetType, 
> targetTypmod,

This does not look terribly sane to me.  AFAICS, the main effect of this
would be that if you have an error in coercing a literal to some
specified type, the error message would point at the literal and not
at the cast operator.  That is, in examples like these:

regression=# select 42::point;
ERROR:  cannot cast type integer to point
LINE 1: select 42::point;
regression=# select cast (42 as point);
ERROR:  cannot cast type integer to point
LINE 1: select cast (42 as point);

you're proposing to move the error pointer to the "42", and that does
not seem like an improvement, especially not if it only happens when the
cast subject is a simple constant rather than an expression.

                        regards, tom lane

Sent via pgsql-hackers mailing list (
To make changes to your subscription:

Reply via email to