PostgreSQL|bpchar Type and the "operator does not exist: character varying = integer" Error
The following SQL worked without issues in versions prior to PostgreSQL 8.3:
select * from table_name where column1 = '0' and column2 = 1;
However, in PostgreSQL 8.3, running this query produces the following error:
ERROR: operator does not exist: character varying = integer at character 69
The cause was that column2 was of type bpchar, yet the numeric value was not enclosed in single quotes. I had never encountered the bpchar type before.
select * from table_name where column1 = '0' and column2 = 1;
↓
select * from table_name where column1 = '0' and column2 = '1';
By enclosing the number in single quotes, the error is resolved.
In earlier versions of PostgreSQL, even if you forgot to quote a value for a bpchar column, the system handled it more flexibly. Starting with version 8.3, however, the behavior has become stricter.
These subtle differences between PostgreSQL 8.2 and 8.3 can be a bit troublesome at times.