mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-27 08:39:28 +08:00
Make handling of INTERVAL DAY TO MINUTE and INTERVAL DAY TO SECOND input
more consistent with other cases, by having an unlabeled integer field be treated as a number of minutes or seconds respectively. These cases are outside the spec (which insists on full "dd hh:mm" or "dd hh:mm:ss" input respectively), so it's not much help to us in deciding what to do. But with this change, it's uniformly the case that an unlabeled integer will be considered as being a number of the interval's rightmost field. The change also takes us back to the 8.3 behavior of throwing error for certain ambiguous inputs such as INTERVAL '1 2' DAY TO MINUTE. Per recent discussion.
This commit is contained in:
parent
0dcc73fea4
commit
5cca35a68b
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.206 2009/06/01 16:55:11 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.207 2009/06/10 05:05:03 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -2917,17 +2917,17 @@ DecodeInterval(char **field, int *ftype, int nf, int range,
|
||||
break;
|
||||
case INTERVAL_MASK(HOUR):
|
||||
case INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR):
|
||||
case INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE):
|
||||
case INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE) | INTERVAL_MASK(SECOND):
|
||||
type = DTK_HOUR;
|
||||
break;
|
||||
case INTERVAL_MASK(MINUTE):
|
||||
case INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE):
|
||||
case INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE):
|
||||
type = DTK_MINUTE;
|
||||
break;
|
||||
case INTERVAL_MASK(SECOND):
|
||||
case INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE) | INTERVAL_MASK(SECOND):
|
||||
case INTERVAL_MASK(MINUTE) | INTERVAL_MASK(SECOND):
|
||||
case INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE) | INTERVAL_MASK(SECOND):
|
||||
case INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE) | INTERVAL_MASK(SECOND):
|
||||
type = DTK_SECOND;
|
||||
break;
|
||||
default:
|
||||
|
@ -466,11 +466,9 @@ SELECT interval '1 2:03:04' day to hour;
|
||||
(1 row)
|
||||
|
||||
SELECT interval '1 2' day to minute;
|
||||
interval
|
||||
----------------
|
||||
1 day 02:00:00
|
||||
(1 row)
|
||||
|
||||
ERROR: invalid input syntax for type interval: "1 2"
|
||||
LINE 1: SELECT interval '1 2' day to minute;
|
||||
^
|
||||
SELECT interval '1 2:03' day to minute;
|
||||
interval
|
||||
----------------
|
||||
@ -484,11 +482,9 @@ SELECT interval '1 2:03:04' day to minute;
|
||||
(1 row)
|
||||
|
||||
SELECT interval '1 2' day to second;
|
||||
interval
|
||||
----------------
|
||||
1 day 02:00:00
|
||||
(1 row)
|
||||
|
||||
ERROR: invalid input syntax for type interval: "1 2"
|
||||
LINE 1: SELECT interval '1 2' day to second;
|
||||
^
|
||||
SELECT interval '1 2:03' day to second;
|
||||
interval
|
||||
----------------
|
||||
@ -605,11 +601,9 @@ SELECT interval '1.234' second(2);
|
||||
(1 row)
|
||||
|
||||
SELECT interval '1 2.345' day to second(2);
|
||||
interval
|
||||
----------------
|
||||
1 day 02:20:42
|
||||
(1 row)
|
||||
|
||||
ERROR: invalid input syntax for type interval: "1 2.345"
|
||||
LINE 1: SELECT interval '1 2.345' day to second(2);
|
||||
^
|
||||
SELECT interval '1 2:03' day to second(2);
|
||||
interval
|
||||
----------------
|
||||
|
Loading…
Reference in New Issue
Block a user