From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: ddtripathy@yahoo.com
Subject: BUG #16247: Cast error on integer
Date: Thu, 06 Feb 2020 21:43:41 +0000
Message-ID: <16247-0a907e8fd6fda1e1@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 16247
Logged by: Dilip Tripathy
Email address: ddtripathy@yahoo.com
PostgreSQL version: 12.1
Operating system: Windows 7 professional
Description:
I have defined a procedure with the following signature:
create or replace procedure eventattributes_getadd(
_cust varchar(128),
_site varchar(128),
_devctrluid int,
_dateid int,
_fiveminprdid smallint,
_metric varchar(128),
_sd varchar(256),
_value varchar(32))
language 'plpgsql'
When I execute the following call it succeeds.
call eventattributes_getadd(
_cust => 'cust'::varchar(128),
_site => 'site'::varchar(128),
_devctrluid => cast (-2147483648 as integer),
_dateid => 20200206::int,
_fiveminprdid => 1700::smallint,
_metric => 'somebogusmetric'::varchar(128),
_sd =>
'>>>ST<<<=mc4;>>>DLN<<<=scanner_1;>>>DG<<<=scanner_1;>>>DGT<<<=scanner;>>>DT<<<=scanner'::varchar(256),
_value => '28'::varchar(32));
However, when I execute the following call I get: ERROR: integer out of
range SQL state: 22003
call eventattributes_getadd(
_cust => 'cust'::varchar(128),
_site => 'site'::varchar(128),
_devctrluid => -2147483648::int,
_dateid => 20200206::int,
_fiveminprdid => 1700::smallint,
_metric => 'somebogusmetric'::varchar(128),
_sd =>
'>>>ST<<<=mc4;>>>DLN<<<=scanner_1;>>>DG<<<=scanner_1;>>>DGT<<<=scanner;>>>DT<<<=scanner'::varchar(256),
_value => '28'::varchar(32));
The only difference between the two calls is how I'm casting the integer.
The second call is choking on "_devctrluid => -2147483648::int". But, if I
change that value to "-2147483647" the second call succeeds.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, ddtripathy@yahoo.com
Subject: Re: BUG #16247: Cast error on integer
In-Reply-To: <16247-0a907e8fd6fda1e1@postgresql.org>
References: <16247-0a907e8fd6fda1e1@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox