Re: BUG #19033: Inconsistency between prepared statement and normal statement when cast bit to integer

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: 798604270(at)qq(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19033: Inconsistency between prepared statement and normal statement when cast bit to integer
Date: 2025-08-27 14:54:55
Message-ID: 1393031.1756306495@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Arseniy Mukhin 2025-08-27 19:17:24 Re: BUG #19031: pg_trgm infinite loop on certain cases
Previous Message David G. Johnston 2025-08-27 14:38:11 Re: BUG #19033: Inconsistency between prepared statement and normal statement when cast bit to integer