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

Commitf3cf330

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 parenteecc150 commitf3cf330

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

44044404
caseDTK_DOW:
44054405
caseDTK_ISODOW:
4406-
if (timestamp2tm(timestamp,NULL,tm,&fsec,NULL,NULL)!=0)
4407-
ereport(ERROR,
4408-
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4409-
errmsg("timestamp out of range")));
44104406
result=j2day(date2j(tm->tm_year,tm->tm_mon,tm->tm_mday));
44114407
if (val==DTK_ISODOW&&result==0)
44124408
result=7;
44134409
break;
44144410

44154411
caseDTK_DOY:
4416-
if (timestamp2tm(timestamp,NULL,tm,&fsec,NULL,NULL)!=0)
4417-
ereport(ERROR,
4418-
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4419-
errmsg("timestamp out of range")));
44204412
result= (date2j(tm->tm_year,tm->tm_mon,tm->tm_mday)
44214413
-date2j(tm->tm_year,1,1)+1);
44224414
break;
@@ -4607,20 +4599,12 @@ timestamptz_part(PG_FUNCTION_ARGS)
46074599

46084600
caseDTK_DOW:
46094601
caseDTK_ISODOW:
4610-
if (timestamp2tm(timestamp,&tz,tm,&fsec,NULL,NULL)!=0)
4611-
ereport(ERROR,
4612-
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4613-
errmsg("timestamp out of range")));
46144602
result=j2day(date2j(tm->tm_year,tm->tm_mon,tm->tm_mday));
46154603
if (val==DTK_ISODOW&&result==0)
46164604
result=7;
46174605
break;
46184606

46194607
caseDTK_DOY:
4620-
if (timestamp2tm(timestamp,&tz,tm,&fsec,NULL,NULL)!=0)
4621-
ereport(ERROR,
4622-
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
4623-
errmsg("timestamp out of range")));
46244608
result= (date2j(tm->tm_year,tm->tm_mon,tm->tm_mday)
46254609
-date2j(tm->tm_year,1,1)+1);
46264610
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp