Peter Geoghegan <peter(at)2ndquadrant(dot)com> 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,
> COERCION_EXPLICIT,
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
In response to
Responses
pgsql-hackers by date
| Next: | From: Tom Lane | Date: 2012-02-21 01:50:58 |
| Subject: Re: Re: pg_stat_statements normalisation without invasive changes to the parser (was: Next steps on pg_stat_statements normalisation) |
| Previous: | From: Adrian Klaver | Date: 2012-02-21 01:37:09 |
| Subject: Re: Unfamous 'could not read block ... in file "...": read only 0 of 8192 bytes' again |