The following bug has been logged online:
Bug reference: 1608
Logged by: Paul
Email address: paul@allinea.com
PostgreSQL version: 8.0.2
Operating system: Gentoo and Fedora Core 3
Description: integer negative limit in plpgsql function arguments
Details:
The script below best sums up the problem (and the work around). The
question is: should I use that for all integers being put into a function?
8<--------------------------------------------
create table test (
test_id integer
);
insert into test (test_id) values (-2147483648);
create function print_test_id (integer) returns integer
AS '
DECLARE
tmp ALIAS FOR $1;
val integer;
BEGIN
select into val test_id from test where test_id = tmp;
return val;
END;
'
LANGUAGE plpgsql;
-- this doesn't work (and I think it should!)
SELECT print_test_id(-2147483648);
-- this is the workaround
SELECT print_test_id((-2147483648)::int);
-------------------------------------------->8