forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit94aa7cc
committed
Add UNIQUE null treatment option
The SQL standard has been ambiguous about whether null values inunique constraints should be considered equal or not. Differentimplementations have different behaviors. In the SQL:202x draft, thishas been formalized by making this implementation-defined and addingan option on unique constraint definitions UNIQUE [ NULLS [NOT]DISTINCT ] to choose a behavior explicitly.This patch adds this option to PostgreSQL. The default behaviorremains UNIQUE NULLS DISTINCT. Making this happen in the btree codeis pretty easy; most of the patch is just to carry the flag around toall the places that need it.The CREATE UNIQUE INDEX syntax extension is not from the standard,it's my own invention.I named all the internal flags, catalog columns, etc. in the negative("nulls not distinct") so that the default PostgreSQL behavior is thedefault if the flag is false.Reviewed-by: Maxim Orlov <orlovmg@gmail.com>Reviewed-by: Pavel Borisov <pashkin.elfe@gmail.com>Discussion:https://www.postgresql.org/message-id/flat/84e5ee1b-387e-9a54-c326-9082674bde78@enterprisedb.com1 parentf862d57 commit94aa7cc
File tree
36 files changed
+348
-57
lines changed- doc/src/sgml
- ref
- src
- backend
- access/nbtree
- catalog
- commands
- nodes
- parser
- utils
- adt
- cache
- sort
- bin
- pg_dump
- psql
- include
- catalog
- nodes
- utils
- test/regress
- expected
- sql
36 files changed
+348
-57
lines changedLines changed: 13 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4265 | 4265 |
| |
4266 | 4266 |
| |
4267 | 4267 |
| |
| 4268 | + | |
| 4269 | + | |
| 4270 | + | |
| 4271 | + | |
| 4272 | + | |
| 4273 | + | |
| 4274 | + | |
| 4275 | + | |
| 4276 | + | |
| 4277 | + | |
| 4278 | + | |
| 4279 | + | |
| 4280 | + | |
4268 | 4281 |
| |
4269 | 4282 |
| |
4270 | 4283 |
| |
|
Lines changed: 24 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
759 | 759 |
| |
760 | 760 |
| |
761 | 761 |
| |
762 |
| - | |
| 762 | + | |
763 | 763 |
| |
764 | 764 |
| |
765 | 765 |
| |
766 |
| - | |
767 |
| - | |
768 |
| - | |
769 |
| - | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
770 | 789 |
| |
771 | 790 |
| |
772 | 791 |
| |
|
Lines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6899 | 6899 |
| |
6900 | 6900 |
| |
6901 | 6901 |
| |
| 6902 | + | |
| 6903 | + | |
| 6904 | + | |
| 6905 | + | |
| 6906 | + | |
| 6907 | + | |
| 6908 | + | |
| 6909 | + | |
| 6910 | + | |
| 6911 | + | |
| 6912 | + | |
| 6913 | + | |
6902 | 6914 |
| |
6903 | 6915 |
| |
6904 | 6916 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
103 | 103 |
| |
104 | 104 |
| |
105 | 105 |
| |
106 |
| - | |
| 106 | + | |
107 | 107 |
| |
108 | 108 |
| |
109 | 109 |
| |
| |||
113 | 113 |
| |
114 | 114 |
| |
115 | 115 |
| |
116 |
| - | |
| 116 | + | |
117 | 117 |
| |
118 | 118 |
| |
119 | 119 |
| |
|
Lines changed: 13 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
24 | 24 |
| |
25 | 25 |
| |
26 | 26 |
| |
| 27 | + | |
27 | 28 |
| |
28 | 29 |
| |
29 | 30 |
| |
| |||
334 | 335 |
| |
335 | 336 |
| |
336 | 337 |
| |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
337 | 350 |
| |
338 | 351 |
| |
339 | 352 |
| |
|
Lines changed: 6 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
67 | 67 |
| |
68 | 68 |
| |
69 | 69 |
| |
70 |
| - | |
| 70 | + | |
71 | 71 |
| |
72 | 72 |
| |
73 | 73 |
| |
| |||
77 | 77 |
| |
78 | 78 |
| |
79 | 79 |
| |
80 |
| - | |
| 80 | + | |
81 | 81 |
| |
82 | 82 |
| |
83 | 83 |
| |
| |||
917 | 917 |
| |
918 | 918 |
| |
919 | 919 |
| |
920 |
| - | |
921 |
| - | |
| 920 | + | |
| 921 | + | |
922 | 922 |
| |
923 | 923 |
| |
924 | 924 |
| |
| |||
934 | 934 |
| |
935 | 935 |
| |
936 | 936 |
| |
937 |
| - | |
| 937 | + | |
| 938 | + | |
938 | 939 |
| |
939 | 940 |
| |
940 | 941 |
| |
|
Lines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
398 | 398 |
| |
399 | 399 |
| |
400 | 400 |
| |
401 |
| - | |
402 |
| - | |
403 |
| - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
404 | 404 |
| |
405 | 405 |
| |
406 | 406 |
| |
|
Lines changed: 13 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
89 | 89 |
| |
90 | 90 |
| |
91 | 91 |
| |
| 92 | + | |
92 | 93 |
| |
93 | 94 |
| |
94 | 95 |
| |
| |||
106 | 107 |
| |
107 | 108 |
| |
108 | 109 |
| |
| 110 | + | |
109 | 111 |
| |
110 | 112 |
| |
111 | 113 |
| |
| |||
206 | 208 |
| |
207 | 209 |
| |
208 | 210 |
| |
| 211 | + | |
209 | 212 |
| |
210 | 213 |
| |
211 | 214 |
| |
| |||
307 | 310 |
| |
308 | 311 |
| |
309 | 312 |
| |
| 313 | + | |
310 | 314 |
| |
311 | 315 |
| |
312 | 316 |
| |
| |||
380 | 384 |
| |
381 | 385 |
| |
382 | 386 |
| |
| 387 | + | |
383 | 388 |
| |
384 | 389 |
| |
385 | 390 |
| |
| |||
429 | 434 |
| |
430 | 435 |
| |
431 | 436 |
| |
| 437 | + | |
432 | 438 |
| |
433 | 439 |
| |
434 | 440 |
| |
| |||
468 | 474 |
| |
469 | 475 |
| |
470 | 476 |
| |
471 |
| - | |
| 477 | + | |
472 | 478 |
| |
473 | 479 |
| |
474 | 480 |
| |
| |||
1554 | 1560 |
| |
1555 | 1561 |
| |
1556 | 1562 |
| |
| 1563 | + | |
1557 | 1564 |
| |
1558 | 1565 |
| |
1559 | 1566 |
| |
| |||
1747 | 1754 |
| |
1748 | 1755 |
| |
1749 | 1756 |
| |
| 1757 | + | |
1750 | 1758 |
| |
1751 | 1759 |
| |
1752 | 1760 |
| |
| |||
1846 | 1854 |
| |
1847 | 1855 |
| |
1848 | 1856 |
| |
| 1857 | + | |
1849 | 1858 |
| |
1850 | 1859 |
| |
1851 | 1860 |
| |
| |||
1928 | 1937 |
| |
1929 | 1938 |
| |
1930 | 1939 |
| |
| 1940 | + | |
1931 | 1941 |
| |
1932 | 1942 |
| |
1933 | 1943 |
| |
| |||
1950 | 1960 |
| |
1951 | 1961 |
| |
1952 | 1962 |
| |
1953 |
| - | |
| 1963 | + | |
1954 | 1964 |
| |
1955 | 1965 |
| |
1956 | 1966 |
| |
1957 | 1967 |
| |
1958 | 1968 |
| |
1959 | 1969 |
| |
| 1970 | + | |
1960 | 1971 |
| |
1961 | 1972 |
| |
1962 | 1973 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
165 | 165 |
| |
166 | 166 |
| |
167 | 167 |
| |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
168 | 175 |
| |
169 | 176 |
| |
170 | 177 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
614 | 614 |
| |
615 | 615 |
| |
616 | 616 |
| |
| 617 | + | |
617 | 618 |
| |
618 | 619 |
| |
619 | 620 |
| |
| |||
1368 | 1369 |
| |
1369 | 1370 |
| |
1370 | 1371 |
| |
| 1372 | + | |
1371 | 1373 |
| |
1372 | 1374 |
| |
1373 | 1375 |
| |
| |||
2440 | 2442 |
| |
2441 | 2443 |
| |
2442 | 2444 |
| |
| 2445 | + | |
2443 | 2446 |
| |
2444 | 2447 |
| |
2445 | 2448 |
| |
| |||
2499 | 2502 |
| |
2500 | 2503 |
| |
2501 | 2504 |
| |
| 2505 | + | |
2502 | 2506 |
| |
2503 | 2507 |
| |
2504 | 2508 |
| |
| |||
2532 | 2536 |
| |
2533 | 2537 |
| |
2534 | 2538 |
| |
| 2539 | + | |
| 2540 | + | |
| 2541 | + | |
2535 | 2542 |
| |
2536 | 2543 |
| |
2537 | 2544 |
| |
|
Lines changed: 7 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1838 | 1838 |
| |
1839 | 1839 |
| |
1840 | 1840 |
| |
1841 |
| - | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
1842 | 1846 |
| |
1843 | 1847 |
| |
1844 | 1848 |
| |
| |||
1868 | 1872 |
| |
1869 | 1873 |
| |
1870 | 1874 |
| |
1871 |
| - | |
| 1875 | + | |
| 1876 | + | |
1872 | 1877 |
| |
1873 | 1878 |
| |
1874 | 1879 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
228 | 228 |
| |
229 | 229 |
| |
230 | 230 |
| |
| 231 | + | |
231 | 232 |
| |
232 | 233 |
| |
233 | 234 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
301 | 301 |
| |
302 | 302 |
| |
303 | 303 |
| |
| 304 | + | |
304 | 305 |
| |
305 | 306 |
| |
306 | 307 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
226 | 226 |
| |
227 | 227 |
| |
228 | 228 |
| |
229 |
| - | |
| 229 | + | |
230 | 230 |
| |
231 | 231 |
| |
232 | 232 |
| |
| |||
867 | 867 |
| |
868 | 868 |
| |
869 | 869 |
| |
| 870 | + | |
870 | 871 |
| |
871 | 872 |
| |
872 | 873 |
| |
|
0 commit comments
Comments
(0)