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

Commitd4c78c1

Browse files
committed
Reject out-of-range dates in to_date().
Dates outside the supported range could be entered, but would not printreasonably, and operations such as conversion to timestamp wouldn't behavesanely either. Since this has the potential to result in undumpable tabledata, it seems worth back-patching.Hitoshi Harada
1 parentdc0c987 commitd4c78c1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3303,6 +3303,12 @@ to_date(PG_FUNCTION_ARGS)
33033303

33043304
do_to_timestamp(date_txt,fmt,&tm,&fsec);
33053305

3306+
if (!IS_VALID_JULIAN(tm.tm_year,tm.tm_mon,tm.tm_mday))
3307+
ereport(ERROR,
3308+
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
3309+
errmsg("date out of range: \"%s\"",
3310+
text_to_cstring(date_txt))));
3311+
33063312
result=date2j(tm.tm_year,tm.tm_mon,tm.tm_mday)-POSTGRES_EPOCH_JDATE;
33073313

33083314
PG_RETURN_DATEADT(result);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp