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

Commitb3b89fd

Browse files
committed
Fix DecodeInterval to report an error for multiple occurrences of DAY, WEEK,
YEAR, DECADE, CENTURY, or MILLENIUM fields, just as it always has done forother types of fields. The previous behavior seems to have been a hack toavoid defining bit-positions for all these field types in DTK_M() masks,rather than something that was really considered to be desired behavior.But there is room in the masks for these, and we really need to tighten upat least the behavior of DAY and YEAR fields to avoid unexpected behaviorassociated with the 8.4 changes to interpret ambiguous fields based on theinterval qualifier (typmod) value. Per my example and proposed patch.
1 parent5377ccb commitb3b89fd

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.205 2009/05/26 02:17:50 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.206 2009/06/01 16:55:11 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -3022,19 +3022,19 @@ DecodeInterval(char **field, int *ftype, int nf, int range,
30223022
tm->tm_hour+=val;
30233023
AdjustFractSeconds(fval,tm,fsec,SECS_PER_HOUR);
30243024
tmask=DTK_M(HOUR);
3025-
type=DTK_DAY;
3025+
type=DTK_DAY;/* set for next field */
30263026
break;
30273027

30283028
caseDTK_DAY:
30293029
tm->tm_mday+=val;
30303030
AdjustFractSeconds(fval,tm,fsec,SECS_PER_DAY);
3031-
tmask=(fmask&DTK_M(DAY)) ?0 :DTK_M(DAY);
3031+
tmask=DTK_M(DAY);
30323032
break;
30333033

30343034
caseDTK_WEEK:
30353035
tm->tm_mday+=val*7;
30363036
AdjustFractDays(fval,tm,fsec,7);
3037-
tmask=(fmask&DTK_M(DAY)) ?0 :DTK_M(DAY);
3037+
tmask=DTK_M(WEEK);
30383038
break;
30393039

30403040
caseDTK_MONTH:
@@ -3047,28 +3047,28 @@ DecodeInterval(char **field, int *ftype, int nf, int range,
30473047
tm->tm_year+=val;
30483048
if (fval!=0)
30493049
tm->tm_mon+=fval*MONTHS_PER_YEAR;
3050-
tmask=(fmask&DTK_M(YEAR)) ?0 :DTK_M(YEAR);
3050+
tmask=DTK_M(YEAR);
30513051
break;
30523052

30533053
caseDTK_DECADE:
30543054
tm->tm_year+=val*10;
30553055
if (fval!=0)
30563056
tm->tm_mon+=fval*MONTHS_PER_YEAR*10;
3057-
tmask=(fmask&DTK_M(YEAR)) ?0 :DTK_M(YEAR);
3057+
tmask=DTK_M(DECADE);
30583058
break;
30593059

30603060
caseDTK_CENTURY:
30613061
tm->tm_year+=val*100;
30623062
if (fval!=0)
30633063
tm->tm_mon+=fval*MONTHS_PER_YEAR*100;
3064-
tmask=(fmask&DTK_M(YEAR)) ?0 :DTK_M(YEAR);
3064+
tmask=DTK_M(CENTURY);
30653065
break;
30663066

30673067
caseDTK_MILLENNIUM:
30683068
tm->tm_year+=val*1000;
30693069
if (fval!=0)
30703070
tm->tm_mon+=fval*MONTHS_PER_YEAR*1000;
3071-
tmask=(fmask&DTK_M(YEAR)) ?0 :DTK_M(YEAR);
3071+
tmask=DTK_M(MILLENNIUM);
30723072
break;
30733073

30743074
default:

‎src/include/utils/datetime.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
12-
* $PostgreSQL: pgsql/src/include/utils/datetime.h,v 1.73 2009/05/26 02:17:50 tgl Exp $
12+
* $PostgreSQL: pgsql/src/include/utils/datetime.h,v 1.74 2009/06/01 16:55:11 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -114,6 +114,11 @@
114114
/* generic fields to help with parsing */
115115
#defineISODATE 22
116116
#defineISOTIME 23
117+
/* these are only for parsing intervals */
118+
#defineWEEK24
119+
#defineDECADE25
120+
#defineCENTURY26
121+
#defineMILLENNIUM27
117122
/* reserved for unrecognized string values */
118123
#defineUNKNOWN_FIELD31
119124

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp