Type and CAST error on lowest negative integer values for smallint, int and bigint - Mailing list pgsql-hackers

From Hans Buschmann
Subject Type and CAST error on lowest negative integer values for smallint, int and bigint
Date
Msg-id 5795b386f0644faf92aa63de3694923b@nidsa.net
Whole thread Raw
Responses Re: Type and CAST error on lowest negative integer values for smallint, int and bigint
List pgsql-hackers

I tried to initialize a table with values for smallint columns.

The final goal is to get mask values for logical operations.


The insert failed with ERROR: smallint out of range.


the same occurs when using a simple select statement like:

select -32768::smallint;
select -2147483648::int;
select -9223372036854775808::bigint;

These limit values are taken from the documentation 8.1.1 Integer Types

This occurs on PG16.2 on Windows or Linux (64bit).

This prevents me to enter the binary value 0b10000000_00000000 into a smallint column
(I could use some other tricks, but this is ugly!)

-----------

postgres=# select version ();
                                                 version
----------------------------------------------------------------------------------------------------------
 PostgreSQL 16.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 14.0.1 20240411 (Red Hat 14.0.1-0), 64-bit
(1 Zeile)

postgres=# select -32768::smallint;
ERROR:  smallint out of range

Thank you for looking


Hans Buschmann

pgsql-hackers by date:

Previous
From: Jelte Fennema-Nio
Date:
Subject: Re: Reducing the log spam
Next
From: David Rowley
Date:
Subject: Re: Type and CAST error on lowest negative integer values for smallint, int and bigint