Re: Unsigned ints (Help) - Mailing list pgsql-hackers

From Adriaan Joubert
Subject Re: Unsigned ints (Help)
Date
Msg-id 3AC2061E.9C0F11A3@albourne.com
Whole thread Raw
In response to Unsigned ints  (Adriaan Joubert <a.joubert@albourne.com>)
Responses Re: Unsigned ints (Help)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Uggh, this needs some help. I've got the problem that I can insert a
value bigger than MAXINT into an int8 column, but when I try to do the
same for a uint4 column, the parser coerces it into an int4, as in:

test=# insert into tint8 values (3043140617);
INSERT 30254 1
test=# insert into tuint4 values (3043140617);
ERROR:  Attribute 'a' is of type 'uint4' but expression is of type
'float8'       You will need to rewrite or cast the expression
test=# insert into tuint4 values (3043140617::uint4);
INSERT 30255 1


Apparently this happens in parse_target.c, from where it calls
CoerceTargetExpr from where it calls routines in parse_coerce.c.

At this point I decided that somewhere in the definition of the type
there must be a way of specifying how values can be transformed. Can
anybody explain to me what I need to change to make this work? Without
this ecpg cannot work with unsigned ints, so explicit casting is not an
option.

Cheers!

Adriaan


pgsql-hackers by date:

Previous
From: Lamar Owen
Date:
Subject: Re: 7.1 RC1 RPM
Next
From: Joel Burton
Date:
Subject: Re: Feature Request: ALTER FUNCTION (or something like that)