Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 083b913

Browse files
committed
On second thought, explain why date_trunc("week") on interval values is
not supported in the error message, rather than the docs.
1 parent 74f4881 commit 083b913

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

doc/src/sgml/func.sgml

-5
Original file line numberDiff line numberDiff line change
@@ -7050,11 +7050,6 @@ date_trunc('<replaceable>field</replaceable>', <replaceable>source</replaceable>
70507050
</simplelist>
70517051
</para>
70527052

7053-
<para>
7054-
<literal>week</literal> is not supported for <type>interval</>
7055-
values because months usually have fractional weeks.
7056-
</para>
7057-
70587053
<para>
70597054
Examples:
70607055
<screen>

src/backend/utils/adt/timestamp.c

+11-4
Original file line numberDiff line numberDiff line change
@@ -3710,10 +3710,17 @@ interval_trunc(PG_FUNCTION_ARGS)
37103710
break;
37113711

37123712
default:
3713-
ereport(ERROR,
3714-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3715-
errmsg("interval units \"%s\" not supported",
3716-
lowunits)));
3713+
if (val == DTK_WEEK)
3714+
ereport(ERROR,
3715+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3716+
errmsg("interval units \"%s\" not supported "
3717+
"because months usually have fractional weeks",
3718+
lowunits)));
3719+
else
3720+
ereport(ERROR,
3721+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3722+
errmsg("interval units \"%s\" not supported",
3723+
lowunits)));
37173724
}
37183725

37193726
if (tm2interval(tm, fsec, result) != 0)

0 commit comments

Comments
 (0)