Re: not null constraints, again
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Tender Wang <tndrwang@gmail.com>,
Pg Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-10-01T08:14:18Z
Lists: pgsql-hackers
CREATE TABLE a (aa TEXT);
CREATE TEMP TABLE z (b TEXT, UNIQUE(aa, b)) inherits (a);
\d+ z
Table "pg_temp_0.z"
Column | Type | Collation | Nullable | Default | Storage |
Compression | Stats target | Description
--------+------+-----------+----------+---------+----------+-------------+--------------+-------------
aa | text | | not null | | extended |
| |
b | text | | | | extended |
| |
Indexes:
"z_aa_b_key" UNIQUE CONSTRAINT, btree (aa, b)
Not-null constraints:
"z_aa_not_null" NOT NULL "aa"
Inherits: a
Access method: heap
that means in transformIndexConstraint,
the following part only apply to CONSTR_PRIMARY
if (strcmp(key, inhname) == 0)
{
found = true;
typid = inhattr->atttypid;
cxt->nnconstraints =
lappend(cxt->nnconstraints,
makeNotNullConstraint(makeString(pstrdup(inhname))));
break;
}
Commits
-
Suppress "may be used uninitialized" warnings from older compilers.
- fc5e966f73f0 18.0 landed
-
Elide not-null constraint checks on child tables during PK creation
- 11ff192b5bb7 18.0 landed
-
Remove unnecessary code to handle CONSTR_NOTNULL
- 5b291d1c9c09 18.0 landed
-
Silence compilers about extractNotNullColumn()
- ff239c3bf4e8 18.0 landed
-
Add pg_constraint rows for not-null constraints
- 14e87ffa5c54 18.0 landed