I can't see that adding full support is likely, since UNSIGNED datatypes are hardly a SQL standard. After all, the primary purpose of supporting them is to make running unit tests for people who are MySQL easier, so it's not like it's a production situation.

But I can see that making them work a little better would be a good idea.
Your best bet is to dig around the Parser class to add support.

On 2013-05-24 10:29, Lukas Eder wrote:
Hello,

I understand that H2 syntactically supports the UNSIGNED keyword in DDL to stay compatible with MySQL:

    CREATE TABLE t_unsigned (
      u_byte tinyint unsigned,
      u_short smallint unsigned,
      u_int int unsigned,
      u_long bigint unsigned
    );

Obviously, this is just a syntax compatibility, as I cannot insert this:

    INSERT INTO t_unsigned (u_byte) VALUES (255);

Would it make sense to enhance the H2 database in order to go a bit further on UNSIGNED support? There are two alternative routes:

--------------------------------------------------------------------------
1. Simple fix: Just "upgrade" integer types in storage, and let the above table be equivalent to this one:

    CREATE TABLE t_unsigned (
      u_byte smallint,
      u_short integer,
      u_int bigint,
      u_long number(20)
    );

2. Sophisticated fix: Store unsigned numbers in signed number containers, but fix all relevant JDBC methods to produce the exact value:

    "255".equals(rs.getString("u_byte"));
    255 == rs.getInt("u_byte");
    (short) 255 == rs.getShort("u_byte");
    (byte) -1 == rs.getByte("u_byte"); // This would be "expected"
--------------------------------------------------------------------------

The simple fix would probably cause new issues in the long run. Besides, it would allow values that are out of range, e.g. 1000 for u_byte. The sophisticated fix would mean a bit of work, specifically because all the arithmetic operations would need to be adapted. Consider

    cast((u_byte + u_byte) as smallint unsigned)

For u_byte == 255 (stored as -1), this would have to return 510, instead of -2

What do you think?

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



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


Reply via email to