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

Commit26ae3aa

Browse files
committed
Remove redundant function calls in timestamp[tz]_part().
The DTK_DOW/DTK_ISODOW and DTK_DOY switch cases in timestamp_part() andtimestamptz_part() contained calls of timestamp2tm() that were fullyredundant with the ones done just above the switch. This evidently creptin during commit258ee1b, which relocated that code from another placewhere the calls were indeed needed. Just delete the redundant calls.I (tgl) noted that our test coverage of these functions left quite abit to be desired, so extend timestamp.sql and timestamptz.sql tocover all the branches.Back-patch to all supported branches, as the previous commit was.There's no real issue here other than some wasted cycles in somenot-too-heavily-used code paths, but the test coverage seems valuable.Report and patch by Li Japin; test case adjustments by me.Discussion:https://postgr.es/m/SG2PR06MB37762CAE45DB0F6CA7001EA9B6550@SG2PR06MB3776.apcprd06.prod.outlook.com
1 parent8ed428d commit26ae3aa

File tree

5 files changed

+693
-395
lines changed

5 files changed

+693
-395
lines changed

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4651,20 +4651,12 @@ timestamp_part(PG_FUNCTION_ARGS)
46514651

46524652
caseDTK_DOW:
46534653
caseDTK_ISODOW:
4654-
if (timestamp2tm(timestamp,NULL,tm,&fsec,NULL,NULL)!=0)
4655-
ereport(ERROR,
4656-
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4657-
errmsg("timestamp out of range")));
46584654
result=j2day(date2j(tm->tm_year,tm->tm_mon,tm->tm_mday));
46594655
if (val==DTK_ISODOW&&result==0)
46604656
result=7;
46614657
break;
46624658

46634659
caseDTK_DOY:
4664-
if (timestamp2tm(timestamp,NULL,tm,&fsec,NULL,NULL)!=0)
4665-
ereport(ERROR,
4666-
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4667-
errmsg("timestamp out of range")));
46684660
result= (date2j(tm->tm_year,tm->tm_mon,tm->tm_mday)
46694661
-date2j(tm->tm_year,1,1)+1);
46704662
break;
@@ -4855,20 +4847,12 @@ timestamptz_part(PG_FUNCTION_ARGS)
48554847

48564848
caseDTK_DOW:
48574849
caseDTK_ISODOW:
4858-
if (timestamp2tm(timestamp,&tz,tm,&fsec,NULL,NULL)!=0)
4859-
ereport(ERROR,
4860-
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4861-
errmsg("timestamp out of range")));
48624850
result=j2day(date2j(tm->tm_year,tm->tm_mon,tm->tm_mday));
48634851
if (val==DTK_ISODOW&&result==0)
48644852
result=7;
48654853
break;
48664854

48674855
caseDTK_DOY:
4868-
if (timestamp2tm(timestamp,&tz,tm,&fsec,NULL,NULL)!=0)
4869-
ereport(ERROR,
4870-
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4871-
errmsg("timestamp out of range")));
48724856
result= (date2j(tm->tm_year,tm->tm_mon,tm->tm_mday)
48734857
-date2j(tm->tm_year,1,1)+1);
48744858
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp