bigint overflow 'feature'

Started by Allan Engelhardtover 24 years ago2 messagesgeneral
Jump to latest
#1Allan Engelhardt
allane@cybaea.com

Just wondering: Is this a known 'feature' & is there a workaround (to catch the overflow and abort the txn)??:

www=# select bigint '9223372036854775807' - bigint '-9223372036854775807';
?column?
----------
-2
(1 row)

PostgreSQL 7.1.3 just downloaded.

Allan.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Allan Engelhardt (#1)
Re: bigint overflow 'feature'

Use NUMERIC if you're concerned about overflow. The integer datatypes
are just C integers, and C doesn't provide any reasonable way to detect
overflow in integer arithmetic...

regards, tom lane