On 03-08-2013 03:55, Mark Rotteveel wrote:
> I just saw this question on Stackoverflow 
> http://stackoverflow.com/questions/18026907/firebird-insert-hex-values-into-tables-arithmetic-exception
> 
> And I wondered if it isn't a bug that hex values with 1-4 digits are 
> integer and not smallint. Or at least: shouldn't the engine have enough 
> context information to correctly convert 0x8000 to a smallint -32768 
> instead of an integer 32768?
> 

It's documented, so it's not a bug.

-------------
Syntax:

<numeric hex literal> ::=
    { 0x | 0X } <hexit> [ <hexit>... ]

<binary string literal> ::=
    { x | X } <quote> [ { <hexit> <hexit> }... ] <quote>

<digit> ::=
    0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

<hexit> ::=
    <digit> | A | B | C | D | E | F | a | b | c | d | e | f

Notes (numeric hex literal):
- The max number of <hexit> should be 16.
- If the number of <hexit> is greater than 8, the constant data type is
a signed BIGINT. If it's
  less or equal than 8, the data type is a signed INTEGER. That means
0xF0000000 is -268435456 and
  0x0F0000000 is 4026531840.

Notes (binary string literal):
- The resulting string is defined as a CHAR(N / 2) CHARACTER SET OCTETS,
where N is the number of <hexit>.

Example:
    select 0x10, cast('0x0F0000000' as bigint) from rdb$database;
    select x'deadbeef' from rdb$database;
-------------

AFAIR, as done initially by Bill Oliver, it was always integer, then I
extended it for bigint and documented.


Adriano

------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to