Re: not null constraints, again

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Tender Wang <tndrwang(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: not null constraints, again
Date: 2024-10-01 08:14:18
Message-ID: CACJufxEKuRzYjHbdA4f61-xiWJp9v_sgNf3TYBqywiK_xNxjUw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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;
}

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2024-10-01 08:17:00 Re: not null constraints, again
Previous Message Alexander Lakhin 2024-10-01 08:00:00 promote request not received timely on slow Windows machines