forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commite056c55
committed
Catalog NOT NULL constraints
We now create pg_constaint rows for NOT NULL constraints withcontype='n'.We propagate these constraints during operations such as addinginheritance relationships, creating and attaching partitions, creatingtables LIKE other tables. We mostly follow the well-known rules ofconislocal and coninhcount that we have for CHECK constraints, with someadaptations; for example, as opposed to CHECK constraints, we don'tmatch NOT NULL ones by name when descending a hierarchy to alter it;instead we match by column number. This means we don't require theconstraint names to be identical across a hierarchy.For now, we omit them from system catalogs. Maybe this is worthreconsidering. We don't support NOT VALID nor DEFERRABLE clauseseither; these can be added as separate features later (this patch isalready large and complicated enough.)This has been very long in the making. The first patch was written byBernd Helmle in 2010 to add a new pg_constraint.contype value ('n'),which I (Álvaro) then hijacked in 2011 and 2012, until that one waskilled by the realization that we ought to use contype='c' instead:manufactured CHECK constraints. However, later SQL standarddevelopment, as well as nonobvious emergent properties of that design(mostly, failure to distinguish them from "normal" CHECK constraints aswell as the performance implication of having to test the CHECKexpression) led us to reconsider this choice, so now the currentimplementation uses contype='n' again.In 2016 Vitaly Burovoy also worked on this feature[1] but found noconsensus for his proposed approach, which was claimed to be closer tothe letter of the standard, requiring additional pg_attribute columns totrack the OID of the NOT NULL constraint for that column.[1]https://postgr.es/m/CAKOSWNkN6HSyatuys8xZxzRCR-KL1OkHS5-b9qd9bf1Rad3PLA@mail.gmail.comAuthor: Álvaro Herrera <alvherre@alvh.no-ip.org>Author: Bernd Helmle <mailings@oopsware.de>Reviewed-by: Justin Pryzby <pryzby@telsasoft.com>Reviewed-by: Peter Eisentraut <peter.eisentraut@enterprisedb.com>Discussion:https://postgr.es/m/CACA0E642A0267EDA387AF2B%40%5B172.26.14.62%5DDiscussion:https://postgr.es/m/AANLkTinLXMOEMz+0J29tf1POokKi4XDkWJ6-DDR9BKgU@mail.gmail.comDiscussion:https://postgr.es/m/20110707213401.GA27098@alvh.no-ip.orgDiscussion:https://postgr.es/m/1343682669-sup-2532@alvh.no-ip.orgDiscussion:https://postgr.es/m/CAKOSWNkN6HSyatuys8xZxzRCR-KL1OkHS5-b9qd9bf1Rad3PLA@mail.gmail.comDiscussion:https://postgr.es/m/20220817181249.q7qvj3okywctra3c@alvherre.pgsql1 parentff245a3 commite056c55
File tree
42 files changed
+2868
-625
lines changed- doc/src/sgml
- ref
- src
- backend
- catalog
- commands
- nodes
- optimizer/util
- parser
- utils/adt
- bin/pg_dump
- t
- include
- catalog
- commands
- nodes
- test
- modules/test_ddl_deparse
- expected
- regress
- expected
- sql
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
42 files changed
+2868
-625
lines changedLines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2552 | 2552 |
| |
2553 | 2553 |
| |
2554 | 2554 |
| |
| 2555 | + | |
2555 | 2556 |
| |
2556 | 2557 |
| |
2557 | 2558 |
| |
|
Lines changed: 11 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
117 | 117 |
| |
118 | 118 |
| |
119 | 119 |
| |
120 |
| - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
121 | 123 |
| |
122 | 124 |
| |
123 | 125 |
| |
| |||
1763 | 1765 |
| |
1764 | 1766 |
| |
1765 | 1767 |
| |
1766 |
| - | |
| 1768 | + | |
1767 | 1769 |
| |
1768 | 1770 |
| |
1769 | 1771 |
| |
1770 |
| - | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
1771 | 1779 |
| |
1772 | 1780 |
| |
1773 | 1781 |
| |
|
Lines changed: 1 addition & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
77 | 77 |
| |
78 | 78 |
| |
79 | 79 |
| |
| 80 | + | |
80 | 81 |
| |
81 | 82 |
| |
82 | 83 |
| |
| |||
2314 | 2315 |
| |
2315 | 2316 |
| |
2316 | 2317 |
| |
2317 |
| - | |
2318 |
| - | |
2319 |
| - | |
2320 |
| - | |
2321 |
| - | |
2322 |
| - | |
2323 |
| - | |
2324 | 2318 |
| |
2325 | 2319 |
| |
2326 | 2320 |
| |
|
0 commit comments
Comments
(0)