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

Commit7335563

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 parent6a9b5a2 commit7335563

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
@@ -4637,20 +4637,12 @@ timestamp_part(PG_FUNCTION_ARGS)
46374637

46384638
caseDTK_DOW:
46394639
caseDTK_ISODOW:
4640-
if (timestamp2tm(timestamp,NULL,tm,&fsec,NULL,NULL)!=0)
4641-
ereport(ERROR,
4642-
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4643-
errmsg("timestamp out of range")));
46444640
result=j2day(date2j(tm->tm_year,tm->tm_mon,tm->tm_mday));
46454641
if (val==DTK_ISODOW&&result==0)
46464642
result=7;
46474643
break;
46484644

46494645
caseDTK_DOY:
4650-
if (timestamp2tm(timestamp,NULL,tm,&fsec,NULL,NULL)!=0)
4651-
ereport(ERROR,
4652-
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4653-
errmsg("timestamp out of range")));
46544646
result= (date2j(tm->tm_year,tm->tm_mon,tm->tm_mday)
46554647
-date2j(tm->tm_year,1,1)+1);
46564648
break;
@@ -4841,20 +4833,12 @@ timestamptz_part(PG_FUNCTION_ARGS)
48414833

48424834
caseDTK_DOW:
48434835
caseDTK_ISODOW:
4844-
if (timestamp2tm(timestamp,&tz,tm,&fsec,NULL,NULL)!=0)
4845-
ereport(ERROR,
4846-
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4847-
errmsg("timestamp out of range")));
48484836
result=j2day(date2j(tm->tm_year,tm->tm_mon,tm->tm_mday));
48494837
if (val==DTK_ISODOW&&result==0)
48504838
result=7;
48514839
break;
48524840

48534841
caseDTK_DOY:
4854-
if (timestamp2tm(timestamp,&tz,tm,&fsec,NULL,NULL)!=0)
4855-
ereport(ERROR,
4856-
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4857-
errmsg("timestamp out of range")));
48584842
result= (date2j(tm->tm_year,tm->tm_mon,tm->tm_mday)
48594843
-date2j(tm->tm_year,1,1)+1);
48604844
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp