- Notifications
You must be signed in to change notification settings - Fork28
Commit46be0c1
committed
> After all that about numbering centuries and millenia correctly,
> why does CVS tip still give me>> regression=# select extract(century from now());> date_part> -----------> 20> (1 row)> [ ... looks in code ... ]>> Apparently it's because you fixed only timestamp_part, and not> timestamptz_part. I'm not too sure about what timestamp_trunc or> timestamptz_trunc should do, but they may be wrong as well.Sigh... as usual, what is not tested does not work:-(> Could we have a more complete patch?Please find a submission attached. I hope it really fixes all decade,century and millenium issues for extract and *_trunc functions onintervaland other timestamp types. If someone could check that the resultsare reasonnable, it would be great.I indeed overlooked the fact that there were two functions. The patchfixes the code so that both variants agree.I added comments to interval extractions, because it relies on the Cdivision to have a negative remainder: -7/10 = 0 and remains -7.As for *_trunc functions, I have chosen to put the first year of thecentury or millennium: -100, 1, 101... 1001 2001 etc. Indeed, I don'tthink it would make sense to put 2000 (last year of the 2nd millennium)for rounding all years of the third millenium.I also fixed the code so that all decades last 10 years and decade 199means the 1990's.I have added some tests that are relevant to deal with tricky cases. Theformula may be simplified, but all these cases must pass. Please keepthem.Fabien Coelho1 parent2674bbb commit46be0c1
File tree
3 files changed
+256
-12
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+256
-12
lines changedLines changed: 73 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
2727 | 2727 |
| |
2728 | 2728 |
| |
2729 | 2729 |
| |
2730 |
| - | |
| 2730 | + | |
| 2731 | + | |
| 2732 | + | |
| 2733 | + | |
| 2734 | + | |
2731 | 2735 |
| |
2732 |
| - | |
| 2736 | + | |
| 2737 | + | |
| 2738 | + | |
| 2739 | + | |
| 2740 | + | |
2733 | 2741 |
| |
2734 |
| - | |
| 2742 | + | |
| 2743 | + | |
| 2744 | + | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
2735 | 2750 |
| |
2736 | 2751 |
| |
2737 | 2752 |
| |
| |||
2830 | 2845 |
| |
2831 | 2846 |
| |
2832 | 2847 |
| |
| 2848 | + | |
2833 | 2849 |
| |
2834 |
| - | |
| 2850 | + | |
| 2851 | + | |
| 2852 | + | |
| 2853 | + | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
| 2857 | + | |
2835 | 2858 |
| |
2836 |
| - | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
| 2862 | + | |
| 2863 | + | |
2837 | 2864 |
| |
2838 |
| - | |
| 2865 | + | |
| 2866 | + | |
| 2867 | + | |
| 2868 | + | |
| 2869 | + | |
| 2870 | + | |
| 2871 | + | |
| 2872 | + | |
| 2873 | + | |
| 2874 | + | |
2839 | 2875 |
| |
2840 | 2876 |
| |
2841 | 2877 |
| |
| |||
2923 | 2959 |
| |
2924 | 2960 |
| |
2925 | 2961 |
| |
| 2962 | + | |
2926 | 2963 |
| |
2927 | 2964 |
| |
| 2965 | + | |
2928 | 2966 |
| |
2929 | 2967 |
| |
| 2968 | + | |
2930 | 2969 |
| |
2931 | 2970 |
| |
2932 | 2971 |
| |
| |||
3221 | 3260 |
| |
3222 | 3261 |
| |
3223 | 3262 |
| |
3224 |
| - | |
| 3263 | + | |
| 3264 | + | |
| 3265 | + | |
| 3266 | + | |
| 3267 | + | |
| 3268 | + | |
| 3269 | + | |
| 3270 | + | |
3225 | 3271 |
| |
3226 | 3272 |
| |
3227 | 3273 |
| |
| |||
3232 | 3278 |
| |
3233 | 3279 |
| |
3234 | 3280 |
| |
3235 |
| - | |
| 3281 | + | |
3236 | 3282 |
| |
3237 | 3283 |
| |
3238 | 3284 |
| |
| |||
3445 | 3491 |
| |
3446 | 3492 |
| |
3447 | 3493 |
| |
3448 |
| - | |
| 3494 | + | |
| 3495 | + | |
| 3496 | + | |
| 3497 | + | |
| 3498 | + | |
3449 | 3499 |
| |
3450 | 3500 |
| |
3451 | 3501 |
| |
3452 |
| - | |
| 3502 | + | |
| 3503 | + | |
| 3504 | + | |
| 3505 | + | |
| 3506 | + | |
3453 | 3507 |
| |
3454 | 3508 |
| |
3455 | 3509 |
| |
3456 |
| - | |
| 3510 | + | |
| 3511 | + | |
| 3512 | + | |
| 3513 | + | |
| 3514 | + | |
3457 | 3515 |
| |
3458 | 3516 |
| |
3459 | 3517 |
| |
| |||
3606 | 3664 |
| |
3607 | 3665 |
| |
3608 | 3666 |
| |
| 3667 | + | |
3609 | 3668 |
| |
3610 | 3669 |
| |
3611 | 3670 |
| |
3612 | 3671 |
| |
| 3672 | + | |
3613 | 3673 |
| |
3614 | 3674 |
| |
3615 | 3675 |
| |
3616 | 3676 |
| |
| 3677 | + | |
3617 | 3678 |
| |
3618 | 3679 |
| |
3619 | 3680 |
| |
|
Lines changed: 149 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
930 | 930 |
| |
931 | 931 |
| |
932 | 932 |
| |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + |
Lines changed: 34 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
235 | 235 |
| |
236 | 236 |
| |
237 | 237 |
| |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + |
0 commit comments
Comments
(0)