Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e1a4dde

Browse files
author
Thomas G. Lockhart
committed
Code modified to reject out of range day of month.
Previously, dates falling within Unix system time range were run through a call to localtime() to get the time zone, if it was not specified. This had the effect that dates with DOMs which were larger than would be valid for that month were "rotated" into the following months.
1 parent 9f98239 commit e1a4dde

File tree

2 files changed

+24
-45
lines changed

2 files changed

+24
-45
lines changed

src/test/regress/expected/datetime.out

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ ZeroSecs
3030

3131
QUERY: SET DateStyle = 'Postgres,noneuropean';
3232
QUERY: SELECT datetime('1994-01-01', '11:00') AS "Jan_01_1994_11am";
33-
Jan_01_1994_11am
33+
Jan_01_1994_11am
3434
----------------------------
3535
Sat Jan 01 11:00:00 1994 PST
3636
(1 row)
@@ -145,6 +145,7 @@ QUERY: INSERT INTO DATETIME_TBL VALUES ('Dec 31 17:32:01 1996');
145145
QUERY: INSERT INTO DATETIME_TBL VALUES ('Jan 01 17:32:01 1997');
146146
QUERY: INSERT INTO DATETIME_TBL VALUES ('Feb 28 17:32:01 1997');
147147
QUERY: INSERT INTO DATETIME_TBL VALUES ('Feb 29 17:32:01 1997');
148+
ERROR: Bad datetime external representation 'Feb 29 17:32:01 1997'
148149
QUERY: INSERT INTO DATETIME_TBL VALUES ('Mar 01 17:32:01 1997');
149150
QUERY: INSERT INTO DATETIME_TBL VALUES ('Dec 30 17:32:01 1997');
150151
QUERY: INSERT INTO DATETIME_TBL VALUES ('Dec 31 17:32:01 1997');
@@ -214,14 +215,13 @@ sixtythree|d1
214215
|Wed Jan 01 17:32:01 1997 PST
215216
|Fri Feb 28 17:32:01 1997 PST
216217
|Sat Mar 01 17:32:01 1997 PST
217-
|Sat Mar 01 17:32:01 1997 PST
218218
|Tue Dec 30 17:32:01 1997 PST
219219
|Wed Dec 31 17:32:01 1997 PST
220220
|Fri Dec 31 17:32:01 1999 PST
221221
|Sat Jan 01 17:32:01 2000 PST
222222
|Sun Dec 31 17:32:01 2000 PST
223223
|Mon Jan 01 17:32:01 2001 PST
224-
(62 rows)
224+
(61 rows)
225225

226226
QUERY: SELECT '' AS fortythree, d1 FROM DATETIME_TBL
227227
WHERE d1 > '1997-01-02'::datetime and d1 != 'current'::datetime;
@@ -263,14 +263,13 @@ fortythree|d1
263263
|Sat Feb 16 17:32:01 2097
264264
|Fri Feb 28 17:32:01 1997 PST
265265
|Sat Mar 01 17:32:01 1997 PST
266-
|Sat Mar 01 17:32:01 1997 PST
267266
|Tue Dec 30 17:32:01 1997 PST
268267
|Wed Dec 31 17:32:01 1997 PST
269268
|Fri Dec 31 17:32:01 1999 PST
270269
|Sat Jan 01 17:32:01 2000 PST
271270
|Sun Dec 31 17:32:01 2000 PST
272271
|Mon Jan 01 17:32:01 2001 PST
273-
(43 rows)
272+
(42 rows)
274273

275274
QUERY: SELECT '' AS fifteen, d1 FROM DATETIME_TBL
276275
WHERE d1 < '1997-01-02'::datetime and d1 != 'current'::datetime;
@@ -355,14 +354,13 @@ fiftyeight|d1
355354
|Wed Jan 01 17:32:01 1997 PST
356355
|Fri Feb 28 17:32:01 1997 PST
357356
|Sat Mar 01 17:32:01 1997 PST
358-
|Sat Mar 01 17:32:01 1997 PST
359357
|Tue Dec 30 17:32:01 1997 PST
360358
|Wed Dec 31 17:32:01 1997 PST
361359
|Fri Dec 31 17:32:01 1999 PST
362360
|Sat Jan 01 17:32:01 2000 PST
363361
|Sun Dec 31 17:32:01 2000 PST
364362
|Mon Jan 01 17:32:01 2001 PST
365-
(58 rows)
363+
(57 rows)
366364

367365
QUERY: SELECT '' AS sixteen, d1 FROM DATETIME_TBL
368366
WHERE d1 <= '1997-01-02'::datetime and d1 != 'current'::datetime;
@@ -427,14 +425,13 @@ fortyfour|d1
427425
|Sat Feb 16 17:32:01 2097
428426
|Fri Feb 28 17:32:01 1997 PST
429427
|Sat Mar 01 17:32:01 1997 PST
430-
|Sat Mar 01 17:32:01 1997 PST
431428
|Tue Dec 30 17:32:01 1997 PST
432429
|Wed Dec 31 17:32:01 1997 PST
433430
|Fri Dec 31 17:32:01 1999 PST
434431
|Sat Jan 01 17:32:01 2000 PST
435432
|Sun Dec 31 17:32:01 2000 PST
436433
|Mon Jan 01 17:32:01 2001 PST
437-
(44 rows)
434+
(43 rows)
438435

439436
QUERY: SELECT '' AS sixtythree, d1 + '1 year'::timespan AS one_year FROM DATETIME_TBL;
440437
sixtythree|one_year
@@ -494,14 +491,13 @@ sixtythree|one_year
494491
|Thu Jan 01 17:32:01 1998 PST
495492
|Sat Feb 28 17:32:01 1998 PST
496493
|Sun Mar 01 17:32:01 1998 PST
497-
|Sun Mar 01 17:32:01 1998 PST
498494
|Wed Dec 30 17:32:01 1998 PST
499495
|Thu Dec 31 17:32:01 1998 PST
500496
|Sun Dec 31 17:32:01 2000 PST
501497
|Mon Jan 01 17:32:01 2001 PST
502498
|Mon Dec 31 17:32:01 2001 PST
503499
|Tue Jan 01 17:32:01 2002 PST
504-
(62 rows)
500+
(61 rows)
505501

506502
QUERY: SELECT '' AS sixtythree, d1 - '1 year'::timespan AS one_year FROM DATETIME_TBL;
507503
sixtythree|one_year
@@ -561,14 +557,13 @@ sixtythree|one_year
561557
|Mon Jan 01 17:32:01 1996 PST
562558
|Wed Feb 28 17:32:01 1996 PST
563559
|Fri Mar 01 17:32:01 1996 PST
564-
|Fri Mar 01 17:32:01 1996 PST
565560
|Mon Dec 30 17:32:01 1996 PST
566561
|Tue Dec 31 17:32:01 1996 PST
567562
|Thu Dec 31 17:32:01 1998 PST
568563
|Fri Jan 01 17:32:01 1999 PST
569564
|Fri Dec 31 17:32:01 1999 PST
570565
|Sat Jan 01 17:32:01 2000 PST
571-
(62 rows)
566+
(61 rows)
572567

573568
QUERY: SELECT '' AS fifty, d1 - '1997-01-02'::datetime AS diff
574569
FROM DATETIME_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
@@ -616,14 +611,13 @@ fifty|diff
616611
|@ 6 hours 27 mins 59 secs ago
617612
|@ 57 days 17 hours 32 mins 1 sec
618613
|@ 58 days 17 hours 32 mins 1 sec
619-
|@ 58 days 17 hours 32 mins 1 sec
620614
|@ 362 days 17 hours 32 mins 1 sec
621615
|@ 363 days 17 hours 32 mins 1 sec
622616
|@ 1093 days 17 hours 32 mins 1 sec
623617
|@ 1094 days 17 hours 32 mins 1 sec
624618
|@ 1459 days 17 hours 32 mins 1 sec
625619
|@ 1460 days 17 hours 32 mins 1 sec
626-
(49 rows)
620+
(48 rows)
627621

628622
QUERY: SELECT '' AS fortynine, date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
629623
date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour,
@@ -673,14 +667,13 @@ fortynine|year|month|day|hour|minute| second
673667
|1997| 1| 1| 17| 32| 1
674668
|1997| 2| 28| 17| 32| 1
675669
|1997| 3| 1| 17| 32| 1
676-
|1997| 3| 1| 17| 32| 1
677670
|1997| 12| 30| 17| 32| 1
678671
|1997| 12| 31| 17| 32| 1
679672
|1999| 12| 31| 17| 32| 1
680673
|2000| 1| 1| 17| 32| 1
681674
|2000| 12| 31| 17| 32| 1
682675
|2001| 1| 1| 17| 32| 1
683-
(49 rows)
676+
(48 rows)
684677

685678
QUERY: SELECT '' AS fortynine, date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec,
686679
date_part( 'usec', d1) AS usec
@@ -729,12 +722,11 @@ fortynine|quarter| msec| usec
729722
| 1| 0| 0
730723
| 1| 0| 0
731724
| 1| 0| 0
732-
| 1| 0| 0
733725
| 4| 0| 0
734726
| 4| 0| 0
735727
| 4| 0| 0
736728
| 1| 0| 0
737729
| 4| 0| 0
738730
| 1| 0| 0
739-
(49 rows)
731+
(48 rows)
740732

src/test/regress/expected/horology.out

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,6 @@ fifty|datetime |year|month|day|hour|minute| second
409409
|Sun Feb 16 17:32:01 1997 PST |1997| 2| 16| 17| 32| 1
410410
|Fri Feb 28 17:32:01 1997 PST |1997| 2| 28| 17| 32| 1
411411
|Sat Mar 01 17:32:01 1997 PST |1997| 3| 1| 17| 32| 1
412-
|Sat Mar 01 17:32:01 1997 PST |1997| 3| 1| 17| 32| 1
413412
|Tue Jun 10 17:32:01 1997 PDT |1997| 6| 10| 17| 32| 1
414413
|Tue Jun 10 18:32:01 1997 PDT |1997| 6| 10| 18| 32| 1
415414
|Tue Dec 30 17:32:01 1997 PST |1997| 12| 30| 17| 32| 1
@@ -419,7 +418,7 @@ fifty|datetime |year|month|day|hour|minute| second
419418
|Sun Dec 31 17:32:01 2000 PST |2000| 12| 31| 17| 32| 1
420419
|Mon Jan 01 17:32:01 2001 PST |2001| 1| 1| 17| 32| 1
421420
|Sat Feb 16 17:32:01 2097 |2097| 2| 16| 17| 32| 1
422-
(50 rows)
421+
(49 rows)
423422

424423
QUERY: SELECT '' AS four, f1 AS abstime,
425424
date_part('year', f1) AS year, date_part('month', f1) AS month,
@@ -593,14 +592,13 @@ sixty_two|us_postgres
593592
|Wed Jan 01 17:32:01 1997 PST
594593
|Fri Feb 28 17:32:01 1997 PST
595594
|Sat Mar 01 17:32:01 1997 PST
596-
|Sat Mar 01 17:32:01 1997 PST
597595
|Tue Dec 30 17:32:01 1997 PST
598596
|Wed Dec 31 17:32:01 1997 PST
599597
|Fri Dec 31 17:32:01 1999 PST
600598
|Sat Jan 01 17:32:01 2000 PST
601599
|Sun Dec 31 17:32:01 2000 PST
602600
|Mon Jan 01 17:32:01 2001 PST
603-
(62 rows)
601+
(61 rows)
604602

605603
QUERY: SELECT '' AS eight, f1 AS us_postgres FROM ABSTIME_TBL;
606604
eight|us_postgres
@@ -674,14 +672,13 @@ sixty_two|us_iso
674672
|1997-01-01 17:32:01-08
675673
|1997-02-28 17:32:01-08
676674
|1997-03-01 17:32:01-08
677-
|1997-03-01 17:32:01-08
678675
|1997-12-30 17:32:01-08
679676
|1997-12-31 17:32:01-08
680677
|1999-12-31 17:32:01-08
681678
|2000-01-01 17:32:01-08
682679
|2000-12-31 17:32:01-08
683680
|2001-01-01 17:32:01-08
684-
(62 rows)
681+
(61 rows)
685682

686683
QUERY: SELECT '' AS eight, f1 AS us_iso FROM ABSTIME_TBL;
687684
eight|us_iso
@@ -757,14 +754,13 @@ sixty_two|us_sql
757754
|01/01/1997 17:32:01.00 PST
758755
|02/28/1997 17:32:01.00 PST
759756
|03/01/1997 17:32:01.00 PST
760-
|03/01/1997 17:32:01.00 PST
761757
|12/30/1997 17:32:01.00 PST
762758
|12/31/1997 17:32:01.00 PST
763759
|12/31/1999 17:32:01.00 PST
764760
|01/01/2000 17:32:01.00 PST
765761
|12/31/2000 17:32:01.00 PST
766762
|01/01/2001 17:32:01.00 PST
767-
(62 rows)
763+
(61 rows)
768764

769765
QUERY: SELECT '' AS eight, f1 AS us_sql FROM ABSTIME_TBL;
770766
eight|us_sql
@@ -847,15 +843,14 @@ sixty_three|european_postgres
847843
|Wed 01 Jan 17:32:01 1997 PST
848844
|Fri 28 Feb 17:32:01 1997 PST
849845
|Sat 01 Mar 17:32:01 1997 PST
850-
|Sat 01 Mar 17:32:01 1997 PST
851846
|Tue 30 Dec 17:32:01 1997 PST
852847
|Wed 31 Dec 17:32:01 1997 PST
853848
|Fri 31 Dec 17:32:01 1999 PST
854849
|Sat 01 Jan 17:32:01 2000 PST
855850
|Sun 31 Dec 17:32:01 2000 PST
856851
|Mon 01 Jan 17:32:01 2001 PST
857852
|Thu 13 Jun 00:00:00 1957 PDT
858-
(63 rows)
853+
(62 rows)
859854

860855
QUERY: SELECT '' AS eight, f1 AS european_postgres FROM ABSTIME_TBL;
861856
eight|european_postgres
@@ -931,15 +926,14 @@ sixty_three|european_iso
931926
|1997-01-01 17:32:01-08
932927
|1997-02-28 17:32:01-08
933928
|1997-03-01 17:32:01-08
934-
|1997-03-01 17:32:01-08
935929
|1997-12-30 17:32:01-08
936930
|1997-12-31 17:32:01-08
937931
|1999-12-31 17:32:01-08
938932
|2000-01-01 17:32:01-08
939933
|2000-12-31 17:32:01-08
940934
|2001-01-01 17:32:01-08
941935
|1957-06-13 00:00:00-07
942-
(63 rows)
936+
(62 rows)
943937

944938
QUERY: SELECT '' AS eight, f1 AS european_iso FROM ABSTIME_TBL;
945939
eight|european_iso
@@ -1015,15 +1009,14 @@ sixty_three|european_sql
10151009
|01/01/1997 17:32:01.00 PST
10161010
|28/02/1997 17:32:01.00 PST
10171011
|01/03/1997 17:32:01.00 PST
1018-
|01/03/1997 17:32:01.00 PST
10191012
|30/12/1997 17:32:01.00 PST
10201013
|31/12/1997 17:32:01.00 PST
10211014
|31/12/1999 17:32:01.00 PST
10221015
|01/01/2000 17:32:01.00 PST
10231016
|31/12/2000 17:32:01.00 PST
10241017
|01/01/2001 17:32:01.00 PST
10251018
|13/06/1957 00:00:00.00 PDT
1026-
(63 rows)
1019+
(62 rows)
10271020

10281021
QUERY: SELECT '' AS eight, f1 AS european_sql FROM ABSTIME_TBL;
10291022
eight|european_sql
@@ -1102,15 +1095,14 @@ sixty_two|us_postgres
11021095
|Wed Jan 01 17:32:01 1997 PST
11031096
|Fri Feb 28 17:32:01 1997 PST
11041097
|Sat Mar 01 17:32:01 1997 PST
1105-
|Sat Mar 01 17:32:01 1997 PST
11061098
|Tue Dec 30 17:32:01 1997 PST
11071099
|Wed Dec 31 17:32:01 1997 PST
11081100
|Fri Dec 31 17:32:01 1999 PST
11091101
|Sat Jan 01 17:32:01 2000 PST
11101102
|Sun Dec 31 17:32:01 2000 PST
11111103
|Mon Jan 01 17:32:01 2001 PST
11121104
|Thu Jun 13 00:00:00 1957 PDT
1113-
(63 rows)
1105+
(62 rows)
11141106

11151107
QUERY: SELECT '' AS eight, f1 AS us_postgres FROM ABSTIME_TBL;
11161108
eight|us_postgres
@@ -1184,15 +1176,14 @@ sixty_two|us_iso
11841176
|1997-01-01 17:32:01-08
11851177
|1997-02-28 17:32:01-08
11861178
|1997-03-01 17:32:01-08
1187-
|1997-03-01 17:32:01-08
11881179
|1997-12-30 17:32:01-08
11891180
|1997-12-31 17:32:01-08
11901181
|1999-12-31 17:32:01-08
11911182
|2000-01-01 17:32:01-08
11921183
|2000-12-31 17:32:01-08
11931184
|2001-01-01 17:32:01-08
11941185
|1957-06-13 00:00:00-07
1195-
(63 rows)
1186+
(62 rows)
11961187

11971188
QUERY: SELECT '' AS eight, f1 AS us_iso FROM ABSTIME_TBL;
11981189
eight|us_iso
@@ -1268,15 +1259,14 @@ sixty_two|us_sql
12681259
|01/01/1997 17:32:01.00 PST
12691260
|02/28/1997 17:32:01.00 PST
12701261
|03/01/1997 17:32:01.00 PST
1271-
|03/01/1997 17:32:01.00 PST
12721262
|12/30/1997 17:32:01.00 PST
12731263
|12/31/1997 17:32:01.00 PST
12741264
|12/31/1999 17:32:01.00 PST
12751265
|01/01/2000 17:32:01.00 PST
12761266
|12/31/2000 17:32:01.00 PST
12771267
|01/01/2001 17:32:01.00 PST
12781268
|06/13/1957 00:00:00.00 PDT
1279-
(63 rows)
1269+
(62 rows)
12801270

12811271
QUERY: SELECT '' AS eight, f1 AS us_sql FROM ABSTIME_TBL;
12821272
eight|us_sql
@@ -1359,7 +1349,6 @@ sixty_three|european_postgres
13591349
|Wed 01 Jan 17:32:01 1997 PST
13601350
|Fri 28 Feb 17:32:01 1997 PST
13611351
|Sat 01 Mar 17:32:01 1997 PST
1362-
|Sat 01 Mar 17:32:01 1997 PST
13631352
|Tue 30 Dec 17:32:01 1997 PST
13641353
|Wed 31 Dec 17:32:01 1997 PST
13651354
|Fri 31 Dec 17:32:01 1999 PST
@@ -1368,7 +1357,7 @@ sixty_three|european_postgres
13681357
|Mon 01 Jan 17:32:01 2001 PST
13691358
|Thu 13 Jun 00:00:00 1957 PDT
13701359
|Thu 13 Jun 00:00:00 1957 PDT
1371-
(64 rows)
1360+
(63 rows)
13721361

13731362
QUERY: SELECT '' AS eight, f1 AS european_postgres FROM ABSTIME_TBL;
13741363
eight|european_postgres
@@ -1444,7 +1433,6 @@ sixty_three|european_iso
14441433
|1997-01-01 17:32:01-08
14451434
|1997-02-28 17:32:01-08
14461435
|1997-03-01 17:32:01-08
1447-
|1997-03-01 17:32:01-08
14481436
|1997-12-30 17:32:01-08
14491437
|1997-12-31 17:32:01-08
14501438
|1999-12-31 17:32:01-08
@@ -1453,7 +1441,7 @@ sixty_three|european_iso
14531441
|2001-01-01 17:32:01-08
14541442
|1957-06-13 00:00:00-07
14551443
|1957-06-13 00:00:00-07
1456-
(64 rows)
1444+
(63 rows)
14571445

14581446
QUERY: SELECT '' AS eight, f1 AS european_iso FROM ABSTIME_TBL;
14591447
eight|european_iso
@@ -1529,7 +1517,6 @@ sixty_three|european_sql
15291517
|01/01/1997 17:32:01.00 PST
15301518
|28/02/1997 17:32:01.00 PST
15311519
|01/03/1997 17:32:01.00 PST
1532-
|01/03/1997 17:32:01.00 PST
15331520
|30/12/1997 17:32:01.00 PST
15341521
|31/12/1997 17:32:01.00 PST
15351522
|31/12/1999 17:32:01.00 PST
@@ -1538,7 +1525,7 @@ sixty_three|european_sql
15381525
|01/01/2001 17:32:01.00 PST
15391526
|13/06/1957 00:00:00.00 PDT
15401527
|13/06/1957 00:00:00.00 PDT
1541-
(64 rows)
1528+
(63 rows)
15421529

15431530
QUERY: SELECT '' AS eight, f1 AS european_sql FROM ABSTIME_TBL;
15441531
eight|european_sql

0 commit comments

Comments
 (0)