Subject Re: [firebird-support] Charset of OCTETS in PK causing problems?
Author Ivan Prenosil
> I finally got around to changing all my Primary Keys and Foreign Keys
> (which are 13 chars and only contain A-Z,0-9) to Charset of OCTETS to
> reduce the space used... with the idea that more space=more indicies
> on page=faster queries
>
> Everything went fine... but now when I run a query like this
>
> SELECT * FROM MYTABLE WHERE ID='123ABC'
>
> it does _not_ find the record ! and it is sitting right there
>
> Now if I change the query to read
>
> SELECT * FROM MYTABLE WHERE ID LIKE '123ABC%'
>
> then it finds the record...

The difference between OCTETS and all other character sets
is with padding character - normal charsets are padded
(when stored to CHAR instead of VARCHAR) with space character,
while OCTETS is padded with binary zeroes.
In your query the string '123ABC' will be internally converted
to character set OCTETS, and should be compared using rules
of OCTETS-charset/OCTETS-collation (i.e. correctly treating
trailing zeroes). Should, but it does not - looks like bug.

Ivan