forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit5835998
committed
Fix interval_transform so it doesn't throw away non-no-op casts.
interval_transform() contained two separate bugs that caused it tosometimes mistakenly decide that a cast from interval to restrictedinterval is a no-op and throw it away.First, it was wrong to rely on dt.h's field type macros to have anordering consistent with the field's significance; in one case they donot. This led to mistakenly treating YEAR as less significant than MONTH,so that a cast from INTERVAL MONTH to INTERVAL YEAR was incorrectlydiscarded.Second, fls(1<<k) produces k+1 not k, so comparing its output directlyto SECOND was wrong. This led to supposing that a cast to INTERVALMINUTE was really a cast to INTERVAL SECOND and so could be discarded.To fix, get rid of the use of fls(), and make a function based onintervaltypmodout to produce a field ID code adapted to the need here.Per bug #14479 from Piotr Stefaniak. Back-patch to 9.2 where transformfunctions were introduced, because this code was born broken.Discussion:https://postgr.es/m/20161227172307.10135.7747@wrigleys.postgresql.org1 parentf60daa3 commit5835998
File tree
3 files changed
+105
-29
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+105
-29
lines changedLines changed: 82 additions & 29 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
922 | 922 |
| |
923 | 923 |
| |
924 | 924 |
| |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 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 | + | |
925 | 978 |
| |
926 | 979 |
| |
927 | 980 |
| |
| |||
943 | 996 |
| |
944 | 997 |
| |
945 | 998 |
| |
946 |
| - | |
947 | 999 |
| |
948 |
| - | |
949 |
| - | |
950 |
| - | |
951 |
| - | |
952 |
| - | |
953 |
| - | |
954 |
| - | |
955 |
| - | |
956 |
| - | |
957 |
| - | |
958 |
| - | |
959 |
| - | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
960 | 1004 |
| |
961 | 1005 |
| |
962 |
| - | |
963 |
| - | |
964 |
| - | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
965 | 1019 |
| |
966 |
| - | |
967 |
| - | |
968 |
| - | |
969 |
| - | |
970 |
| - | |
971 |
| - | |
972 |
| - | |
973 |
| - | |
974 |
| - | |
975 |
| - | |
976 |
| - | |
977 |
| - | |
978 |
| - | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
979 | 1032 |
| |
980 | 1033 |
| |
981 | 1034 |
| |
|
Lines changed: 18 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
692 | 692 |
| |
693 | 693 |
| |
694 | 694 |
| |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
695 | 713 |
| |
696 | 714 |
| |
697 | 715 |
| |
|
Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
198 | 198 |
| |
199 | 199 |
| |
200 | 200 |
| |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
201 | 206 |
| |
202 | 207 |
| |
203 | 208 |
| |
|
0 commit comments
Comments
(0)