Thread: pgsql: Coerce 'unknown' type parameters to the right type in the

pgsql: Coerce 'unknown' type parameters to the right type in the

From
heikki@postgresql.org (Heikki Linnakangas)
Date:
Log Message:
-----------
Coerce 'unknown' type parameters to the right type in the fixed-params
parse_analyze() function. That case occurs e.g with PL/pgSQL
EXECUTE ... USING 'stringconstant'.

The coercion with a CoerceViaIO node. The result is similar to the coercion
via input function performed for unknown constants in coerce_type(),
except that this happens at runtime.

Backpatch to 9.0. The issue is present in 8.4 as well, but the coerce param
hook infrastructure this patch relies on was introduced in 9.0. Given the
lack of user reports and harmlessness of the bug, it's not worth attempting
a different fix just for 8.4.

Modified Files:
--------------
    pgsql/src/backend/parser:
        parse_param.c (r2.4 -> r2.5)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_param.c?r1=2.4&r2=2.5)

Re: pgsql: Coerce 'unknown' type parameters to the right type in the

From
Tom Lane
Date:
heikki@postgresql.org (Heikki Linnakangas) writes:
> Log Message:
> -----------
> Coerce 'unknown' type parameters to the right type in the fixed-params
> parse_analyze() function. That case occurs e.g with PL/pgSQL
> EXECUTE ... USING 'stringconstant'.

> The coercion with a CoerceViaIO node. The result is similar to the coercion
> via input function performed for unknown constants in coerce_type(),
> except that this happens at runtime.

Unfortunately, this entirely fails to enforce the rule that an unknown
Param be coerced the same way everywhere.  You'd need a cleanup pass as
well, cf check_variable_parameters().

            regards, tom lane

Re: pgsql: Coerce 'unknown' type parameters to the right type in the

From
Heikki Linnakangas
Date:
On 18/08/10 16:57, Tom Lane wrote:
> heikki@postgresql.org (Heikki Linnakangas) writes:
>> Log Message:
>> -----------
>> Coerce 'unknown' type parameters to the right type in the fixed-params
>> parse_analyze() function. That case occurs e.g with PL/pgSQL
>> EXECUTE ... USING 'stringconstant'.
>
>> The coercion with a CoerceViaIO node. The result is similar to the coercion
>> via input function performed for unknown constants in coerce_type(),
>> except that this happens at runtime.
>
> Unfortunately, this entirely fails to enforce the rule that an unknown
> Param be coerced the same way everywhere.  You'd need a cleanup pass as
> well, cf check_variable_parameters().

Yeah, you're right. I'll find a way to do the cleanup pass in fixed
params case too.

--
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com