forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit085f931
committed
Allow numeric scale to be negative or greater than precision.
Formerly, when specifying NUMERIC(precision, scale), the scale had tobe in the range [0, precision], which was per SQL spec. This commitextends the range of allowed scales to [-1000, 1000], independent ofthe precision (whose valid range remains [1, 1000]).A negative scale implies rounding before the decimal point. Forexample, a column might be declared with a scale of -3 to round valuesto the nearest thousand. Note that the display scale remainsnon-negative, so in this case the display scale will be zero, and alldigits before the decimal point will be displayed.A scale greater than the precision supports fractional values withzeros immediately after the decimal point.Take the opportunity to tidy up the code that packs, unpacks andvalidates the contents of a typmod integer, encapsulating it in asmall set of new inline functions.Bump the catversion because the allowed contents of atttypmod havechanged for numeric columns. This isn't a change that requires are-initdb, but negative scale values in the typmod would confuse oldbackends.Dean Rasheed, with additional improvements by Tom Lane. Reviewed byTom Lane.Discussion:https://postgr.es/m/CAEZATCWdNLgpKihmURF8nfofP0RFtAKJ7ktY6GcZOPnMfUoRqA@mail.gmail.com1 parentefe0802 commit085f931
File tree
7 files changed
+251
-43
lines changed- doc/src/sgml
- src
- backend/utils/adt
- include
- catalog
- utils
- test/regress
- expected
- sql
7 files changed
+251
-43
lines changedLines changed: 44 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
545 | 545 |
| |
546 | 546 |
| |
547 | 547 |
| |
548 |
| - | |
549 |
| - | |
| 548 | + | |
| 549 | + | |
550 | 550 |
| |
551 | 551 |
| |
552 | 552 |
| |
| |||
569 | 569 |
| |
570 | 570 |
| |
571 | 571 |
| |
572 |
| - | |
573 |
| - | |
| 572 | + | |
| 573 | + | |
574 | 574 |
| |
575 | 575 |
| |
576 | 576 |
| |
| |||
581 | 581 |
| |
582 | 582 |
| |
583 | 583 |
| |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
584 | 613 |
| |
585 | 614 |
| |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
586 | 626 |
| |
587 | 627 |
| |
588 | 628 |
| |
|
Lines changed: 95 additions & 35 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
815 | 815 |
| |
816 | 816 |
| |
817 | 817 |
| |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
818 | 874 |
| |
819 | 875 |
| |
820 | 876 |
| |
| |||
826 | 882 |
| |
827 | 883 |
| |
828 | 884 |
| |
829 |
| - | |
| 885 | + | |
830 | 886 |
| |
831 | 887 |
| |
832 | 888 |
| |
833 |
| - | |
| 889 | + | |
834 | 890 |
| |
835 | 891 |
| |
836 | 892 |
| |
| |||
1084 | 1140 |
| |
1085 | 1141 |
| |
1086 | 1142 |
| |
1087 |
| - | |
1088 |
| - | |
1089 |
| - | |
1090 |
| - | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
1091 | 1147 |
| |
1092 | 1148 |
| |
1093 |
| - | |
1094 |
| - | |
| 1149 | + | |
| 1150 | + | |
1095 | 1151 |
| |
1096 | 1152 |
| |
1097 | 1153 |
| |
1098 | 1154 |
| |
1099 |
| - | |
1100 |
| - | |
| 1155 | + | |
| 1156 | + | |
1101 | 1157 |
| |
1102 | 1158 |
| |
1103 | 1159 |
| |
| |||
1119 | 1175 |
| |
1120 | 1176 |
| |
1121 | 1177 |
| |
1122 |
| - | |
1123 | 1178 |
| |
1124 | 1179 |
| |
1125 | 1180 |
| |
1126 | 1181 |
| |
| 1182 | + | |
1127 | 1183 |
| |
1128 | 1184 |
| |
1129 | 1185 |
| |
| |||
1140 | 1196 |
| |
1141 | 1197 |
| |
1142 | 1198 |
| |
1143 |
| - | |
| 1199 | + | |
1144 | 1200 |
| |
1145 | 1201 |
| |
1146 | 1202 |
| |
1147 | 1203 |
| |
1148 | 1204 |
| |
1149 |
| - | |
1150 |
| - | |
1151 |
| - | |
| 1205 | + | |
| 1206 | + | |
1152 | 1207 |
| |
1153 | 1208 |
| |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
1154 | 1212 |
| |
1155 | 1213 |
| |
1156 | 1214 |
| |
| |||
1160 | 1218 |
| |
1161 | 1219 |
| |
1162 | 1220 |
| |
1163 |
| - | |
| 1221 | + | |
1164 | 1222 |
| |
1165 | 1223 |
| |
1166 | 1224 |
| |
1167 | 1225 |
| |
1168 | 1226 |
| |
1169 | 1227 |
| |
1170 |
| - | |
| 1228 | + | |
1171 | 1229 |
| |
1172 | 1230 |
| |
1173 |
| - | |
| 1231 | + | |
1174 | 1232 |
| |
1175 | 1233 |
| |
1176 | 1234 |
| |
| |||
1206 | 1264 |
| |
1207 | 1265 |
| |
1208 | 1266 |
| |
1209 |
| - | |
| 1267 | + | |
1210 | 1268 |
| |
1211 | 1269 |
| |
1212 |
| - | |
1213 |
| - | |
1214 |
| - | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
1215 | 1273 |
| |
1216 | 1274 |
| |
1217 | 1275 |
| |
| |||
1221 | 1279 |
| |
1222 | 1280 |
| |
1223 | 1281 |
| |
1224 |
| - | |
| 1282 | + | |
1225 | 1283 |
| |
1226 | 1284 |
| |
1227 | 1285 |
| |
| |||
1240 | 1298 |
| |
1241 | 1299 |
| |
1242 | 1300 |
| |
1243 |
| - | |
| 1301 | + | |
1244 | 1302 |
| |
1245 |
| - | |
1246 |
| - | |
| 1303 | + | |
| 1304 | + | |
1247 | 1305 |
| |
1248 | 1306 |
| |
1249 | 1307 |
| |
| |||
7428 | 7486 |
| |
7429 | 7487 |
| |
7430 | 7488 |
| |
7431 |
| - | |
7432 |
| - | |
| 7489 | + | |
| 7490 | + | |
7433 | 7491 |
| |
7434 | 7492 |
| |
7435 |
| - | |
7436 |
| - | |
7437 |
| - | |
| 7493 | + | |
| 7494 | + | |
7438 | 7495 |
| |
7439 | 7496 |
| |
7440 | 7497 |
| |
7441 | 7498 |
| |
7442 | 7499 |
| |
| 7500 | + | |
| 7501 | + | |
| 7502 | + | |
| 7503 | + | |
7443 | 7504 |
| |
7444 | 7505 |
| |
7445 | 7506 |
| |
| |||
7514 | 7575 |
| |
7515 | 7576 |
| |
7516 | 7577 |
| |
7517 |
| - | |
| 7578 | + | |
7518 | 7579 |
| |
7519 | 7580 |
| |
7520 |
| - | |
7521 |
| - | |
7522 |
| - | |
| 7581 | + | |
| 7582 | + | |
7523 | 7583 |
| |
7524 | 7584 |
| |
7525 | 7585 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
53 | 53 |
| |
54 | 54 |
| |
55 | 55 |
| |
56 |
| - | |
| 56 | + | |
57 | 57 |
| |
58 | 58 |
|
Lines changed: 13 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
17 | 17 |
| |
18 | 18 |
| |
19 | 19 |
| |
20 |
| - | |
21 |
| - | |
22 |
| - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
23 | 30 |
| |
24 | 31 |
| |
25 | 32 |
| |
| 33 | + | |
| 34 | + | |
| 35 | + | |
26 | 36 |
| |
27 | 37 |
| |
28 | 38 |
| |
|
0 commit comments
Comments
(0)