From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | kjs(at)teews(dot)com |
Subject: | BUG #17128: minimum numeric 'integer' is -2147483647 not -2147483648 as documented |
Date: | 2021-07-29 22:35:01 |
Message-ID: | 17128-55a8a879727a3e3a@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 17128
Logged by: Kevin Sweet
Email address: kjs(at)teews(dot)com
PostgreSQL version: 13.2
Operating system: RHEL6, RHEL7, Solaris11
Description:
I submitted a similar report to the documentation mailing list so you can
decide whether to update the documentation or the code.
The PGTYPESnumeric_to_int function deems -2147483648 to be invalid even
though it is a perfectly valid 32-bit integer because the code compares to
-INT_MAX which resolves to -2147483647 on the Fedora/Red Hat and Solaris
versions I have available to check against.
diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml
index 7266e229a4..0e89f23c73 100644
--- a/doc/src/sgml/ecpg.sgml
+++ b/doc/src/sgml/ecpg.sgml
@@ -8666,7 +8666,7 @@ int dectoint(decimal *np, int *ip);
Note that the ECPG implementation differs from the
<productname>Informix</productname>
implementation. <productname>Informix</productname> limits an
integer to the range from -32767 to
32767, while the limits in the ECPG implementation depend on the
- architecture (<literal>-INT_MAX .. INT_MAX</literal>).
+ architecture (<literal>(-INT_MAX - 1) .. INT_MAX</literal>).
</para>
</listitem>
</varlistentry>
diff --git a/src/interfaces/ecpg/pgtypeslib/numeric.c
b/src/interfaces/ecpg/pgtypeslib/numeric.c
index 060fad7867..4e6c9910dc 100644
--- a/src/interfaces/ecpg/pgtypeslib/numeric.c
+++ b/src/interfaces/ecpg/pgtypeslib/numeric.c
@@ -1505,7 +1505,7 @@ PGTYPESnumeric_to_int(numeric *nv, int *ip)
if ((i = PGTYPESnumeric_to_long(nv, &l)) != 0)
return i;
- if (l < -INT_MAX || l > INT_MAX)
+ if (l < (-INT_MAX - 1) || l > INT_MAX)
{
errno = PGTYPES_NUM_OVERFLOW;
return -1;
From | Date | Subject | |
---|---|---|---|
Next Message | Noah Misch | 2021-07-30 02:25:48 | Re: CREATE INDEX CONCURRENTLY does not index prepared xact's data |
Previous Message | Thomas Munro | 2021-07-29 21:41:33 | Re: BUG #17116: Assert failed in SerialSetActiveSerXmin() on commit of parallelized serializable transaction |