Re: [Info-ingres] no unsigned data types in ingres sql




"Karl & Betty Schendel" <schendel@xxxxxxxxxxxxxx> wrote in message
news:mailman.1126200001.15354.info-ingres@xxxxxxxxxxxxxxxxxx
> At 5:30 PM +0100 9/8/2005, morgan brickley wrote:
> >I've noticed that there's no unsigned data types in ingres sql. This is
a problem for us as we need to allow access to a table usign unsigned 64-bit
integers generated from afar (an authentication agent)...The current
solution is to base64 encode the 8byte values, producing 11byte varchars
that can at least be stored, compared etc. safely. The further I go with
this solution however the less I like it as I need to do quite a bit of
base64 encoding and decoding in python, where previouslt I could do inserts
etc with no fear of overflowing...
> >
> >ie. I'm using the python dbi driver to execute strings containing CRUD
operations like
> >
> >INSERT into table (id) values (someNumberGreaterThan2TothePowerOf63)
> >
> >will produce an error as someNumberGreaterThan2TothePowerOf63 is in
string form and will be out of range.
>
> The SQL Standard doesn't allow for unsigned numeric types.
>
> You can however take your unsigned number and send it to Ingres as if it
> were signed. E.g. 2703443303 (0xa1234567) can be sent as -1591523993.
> It's the same bit-pattern, just ascii-ized differently.

I'd be uncomfortable using a signed type for an unsigned value because it
admits meaningless operations on the data, and worse still, apparently
meaningful operations that are wrong. How about using BYTE(4) or BYTE(8)?
In fact I would guess these types are *exactly* what is needed, since the
value being stored is probably not from a domain in which integer arithmetic
is even defined.

Roy Hann (rhann at rationalcommerce dot com)
Rational Commerce Ltd.
www.rationalcommerce.com
"Ingres development, tuning, and training experts"


.