Hello,

According to ``lang_expr.html#hexint'':

``...0x8000000000000000 means the same as -9223372036854775808.
Hexadecimal integer literals are interpreted as 64-bit two's-complement
integers...''.

Not necessary:

``SELECT - -9223372036854775808;'' => 9.22337203685478e+18. Ok.
``SELECT -0x8000000000000000;'' => -9223372036854775808. Error.

Ad-hoc solution: src/expr.c, codeInteger(), replace lines:

======
       if( negFlag ){ value = c==2 ? SMALLEST_INT64 : -value; }
       sqlite3VdbeAddOp4Dup8(v, OP_Int64, 0, iMem, 0, (u8*)&value, 
P4_INT64);
======

with

======
       if( negFlag ) {
         if ( 0 == c && SMALLEST_INT64 == value ) {
#ifdef SQLITE_OMIT_FLOATING_POINT
           sqlite3ErrorMsg(pParse, "oversized integer: %s%s", negFlag ? 
"-" : "", z);
#else
           double dValue = -(double)value;
           sqlite3VdbeAddOp4Dup8(v, OP_Real, 0, iMem, 0, (u8*)&dValue, 
P4_REAL);
#endif
           return;
         }
         value = c==2 ? SMALLEST_INT64 : -value;
       }
       sqlite3VdbeAddOp4Dup8(v, OP_Int64, 0, iMem, 0, (u8*)&value, 
P4_INT64);
======

-- best regards

Cezary H. Noweta

Reply via email to