Re: Re: pg_stat_statements normalisation without invasive changes to the parser (was: Next steps on pg_stat_statements normalisation)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Geoghegan <peter(at)2ndquadrant(dot)com>
Cc: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Re: pg_stat_statements normalisation without invasive changes to the parser (was: Next steps on pg_stat_statements normalisation)
Date: 2012-02-21 01:48:30
Message-ID: 21995.1329788910@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-02-21 01:50:58 Re: Re: pg_stat_statements normalisation without invasive changes to the parser (was: Next steps on pg_stat_statements normalisation)
Previous Message Adrian Klaver 2012-02-21 01:37:09 Re: Unfamous 'could not read block ... in file "...": read only 0 of 8192 bytes' again