Tricky.

In this case
   org.h2.value.ValueBytes#compareSecure
is calling
   org.h2.util.Utils#compareNotNull(byte[], byte[])
to do the comparison, and it treats the data as a sequence of signed bytes.

Since, for example, 0x99 == -103, it naturally sorts below 0x09.

You should really not be relying on any kind of sort order when it comes to BINARY columns, any sort order we could define over it would always be unsuitable to someone.

On 2012-12-10 15:14, Matthew Painter wrote:
Hi all,

Just wanted to check that this is a bug:

create table bin( x binary(1) );
insert into bin(x) values (x'09'),(x'0a'),(x'99'),(x'aa');
select * from bin order by x;

X<http://localhost:8082/query.do?jsessionid=6f1c7d9767ef118f4a6200a29c62d7ab#>
99
aa
09
0a

(4 rows, 0 ms)

The sorting should of course be:

X<http://localhost:8082/query.do?jsessionid=6f1c7d9767ef118f4a6200a29c62d7ab#>
09
0a
99
aa

(4 rows, 0 ms)

Am I right in thinking this is a bug? Or is there an obscure setting to correct his?


Thanks :)


Matt --
You received this message because you are subscribed to the Google Groups "H2 Database" group. To view this discussion on the web visit https://groups.google.com/d/msg/h2-database/-/Kib7PA3uF4wJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.

--
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to