Re: Unsigned ints (Help)

From: Adriaan Joubert <a(dot)joubert(at)albourne(dot)com>
To: Postgresql <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unsigned ints (Help)
Date: 2001-03-28 15:41:18
Message-ID: 3AC2061E.9C0F11A3@albourne.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joel Burton 2001-03-28 15:52:28 Re: Feature Request: ALTER FUNCTION (or something like that)
Previous Message Tom Lane 2001-03-28 15:22:56 Re: pg_dump potential bug