Hey — I have a question about automatic binary casting.
I was just doing some random tests and stumbled on the following issue. This query prints just fine from MemSQL Studio, but using the MariaDB JDBC driver it displays as all undifferentiated byte arrays:
(select v from eavt_bytes limit 10) -- table whose values are byte arrays / `longblob`
union
(select v from eavt_long limit 10); -- table whose values are `bigint`
(For reference’s sake, the number 5
displays via JDBC as the byte array [53]
, and the number 10
displays as [49, 48]
.)
One workaround is this — it prints correctly via JDBC — but it’s not ideal:
(select v, null from eavt_bytes limit 10)
union
(select null, v from eavt_long limit 10);
Another better option is this (having a column marking the datatype) but has the disadvantage of still printing wrong via JDBC:
(select 0, v from eavt_bytes limit 10)
union
(select 1, v from eavt_long limit 10);
I saw at SingleStoreDB Cloud · SingleStore Documentation that There is usually no visible effect on the printed value; what changes is the rules for comparison and sorting.
What logic does the MemSQL console have that displays these bigint
values correctly where JDBC does not? I’m sure I’m missing something here. I could probably reverse engineer it but would be nice to not have to take the time