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

Commit083b913

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 parent74f4881 commit083b913

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 0 additions & 5 deletions
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

Lines changed: 11 additions & 4 deletions
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)

[8]ページ先頭

©2009-2025 Movatter.jp