File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -958,6 +958,7 @@ interval_transform(PG_FUNCTION_ARGS)
958958 int new_range = INTERVAL_RANGE (new_typmod );
959959 int new_precis = INTERVAL_PRECISION (new_typmod );
960960 int new_range_fls ;
961+ int old_range_fls ;
961962
962963 if (old_typmod == -1 )
963964 {
@@ -974,12 +975,16 @@ interval_transform(PG_FUNCTION_ARGS)
974975 * Temporally-smaller fields occupy higher positions in the range
975976 * bitmap. Since only the temporally-smallest bit matters for length
976977 * coercion purposes, we compare the last-set bits in the ranges.
978+ * Precision, which is to say, sub-second precision, only affects
979+ * ranges that include SECOND.
977980 */
978981 new_range_fls = fls (new_range );
982+ old_range_fls = fls (old_range );
979983 if (new_typmod == -1 ||
980984 ((new_range_fls >= SECOND ||
981- new_range_fls >= fls (old_range )) &&
982- (new_precis >= MAX_INTERVAL_PRECISION ||
985+ new_range_fls >= old_range_fls ) &&
986+ (old_range_fls < SECOND ||
987+ new_precis >= MAX_INTERVAL_PRECISION ||
983988 new_precis >= old_precis )))
984989 ret = relabel_to_typmod (source , new_typmod );
985990 }
You can’t perform that action at this time.
0 commit comments