PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> PREPARE prepare_query (unknown) AS SELECT $1::INT;
> EXECUTE prepare_query(B'1111');
> ERROR: parameter $1 of type bit cannot be coerced to the expected type
> integer
The reason that fails is that EvaluateParams uses assignment-coercion
semantics, which is more limited in what it will allow than an
explicit coercion. I think this is correct behavior. The system
should not silently perform cross-type-category casts --- too much
risk of unintended results.
regards, tom lane