Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6656588

Browse files
committed
Improve interval_transform function to detect a few more cases.
Noah Misch, per a review comment from me.
1 parentd7ea919 commit6656588

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

‎src/backend/utils/adt/timestamp.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,7 @@ interval_transform(PG_FUNCTION_ARGS)
958958
intnew_range=INTERVAL_RANGE(new_typmod);
959959
intnew_precis=INTERVAL_PRECISION(new_typmod);
960960
intnew_range_fls;
961+
intold_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
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp