Text to interval conversion can silently truncate data - Mailing list pgsql-general

From Jack Christensen
Subject Text to interval conversion can silently truncate data
Date
Msg-id 55944DCE.4090601@jackchristensen.com
Whole thread Raw
Responses Re: Text to interval conversion can silently truncate data
List pgsql-general
jack=# select '1.51 years'::interval = '1.52 years'::interval;
 ?column?
----------
 t
(1 row)

This is surprising. Once I looked at the C code for Interval it makes more sense given that it cannot represent fractional years, months, or days. Wouldn't it make more sense to raise an invalid input error than to silently truncate data?

Jack

pgsql-general by date:

Previous
From: Arthur Silva
Date:
Subject: Re: Which replication is the best for our case ?
Next
From: Tom Lane
Date:
Subject: Re: Text to interval conversion can silently truncate data