1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-22 12:22:45 +03:00

Catalog domain not-null constraints

This applies the explicit catalog representation of not-null
constraints introduced by b0e96f3119 for table constraints also to
domain not-null constraints.

Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: jian he <jian.universality@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/9ec24d7b-633d-463a-84c6-7acff769c9e8%40eisentraut.org
This commit is contained in:
Peter Eisentraut
2024-03-20 09:29:08 +01:00
parent c9c260decd
commit e5da0fe3c2
10 changed files with 386 additions and 115 deletions

View File

@@ -2496,15 +2496,23 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
}
case CONSTRAINT_NOTNULL:
{
AttrNumber attnum;
if (conForm->conrelid)
{
AttrNumber attnum;
attnum = extractNotNullColumn(tup);
attnum = extractNotNullColumn(tup);
appendStringInfo(&buf, "NOT NULL %s",
quote_identifier(get_attname(conForm->conrelid,
attnum, false)));
if (((Form_pg_constraint) GETSTRUCT(tup))->connoinherit)
appendStringInfoString(&buf, " NO INHERIT");
appendStringInfo(&buf, "NOT NULL %s",
quote_identifier(get_attname(conForm->conrelid,
attnum, false)));
if (((Form_pg_constraint) GETSTRUCT(tup))->connoinherit)
appendStringInfoString(&buf, " NO INHERIT");
}
else if (conForm->contypid)
{
/* conkey is null for domain not-null constraints */
appendStringInfoString(&buf, "NOT NULL VALUE");
}
break;
}

View File

@@ -1071,7 +1071,7 @@ load_domaintype_info(TypeCacheEntry *typentry)
Expr *check_expr;
DomainConstraintState *r;
/* Ignore non-CHECK constraints (presently, shouldn't be any) */
/* Ignore non-CHECK constraints */
if (c->contype != CONSTRAINT_CHECK)
continue;