Commit 621e372
Thomas G. Lockhart
Repair two recently reported problems:
1) datetime_pl_span() added the seconds field before adding the months
field. This lead to erroneous results for e.g.
select datetime '1999-11-30' + timespan '1 mon - 1 sec';
Reverse the order of operations to add months first.
2) tm2timespan() did all intermediate math as integer, converting to double
at the very end. This resulted in hidden overflows when given very large
integer days, hours, etc. For example,
select '74565 days'::timespan;
produced the wrong result. Change code to ensure that doubles are used
for intermediate calculations.
Thanks to Olivier PRENANT <ohp@pyrenet.fr> and
Tulassay Zsolt <zsolt@tek.bke.hu> for problem reports and to Tom Lane for
accurate analyses.1 parent 424ff56 commit 621e372
1 file changed
+12
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
811 | 811 | | |
812 | 812 | | |
813 | 813 | | |
| 814 | + | |
814 | 815 | | |
815 | 816 | | |
816 | 817 | | |
| |||
843 | 844 | | |
844 | 845 | | |
845 | 846 | | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
851 | | - | |
852 | 847 | | |
853 | 848 | | |
854 | 849 | | |
| |||
889 | 884 | | |
890 | 885 | | |
891 | 886 | | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
892 | 893 | | |
893 | 894 | | |
894 | 895 | | |
| |||
2569 | 2570 | | |
2570 | 2571 | | |
2571 | 2572 | | |
2572 | | - | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
2573 | 2577 | | |
2574 | 2578 | | |
2575 | 2579 | | |
| |||
0 commit comments