aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2024-03-20 09:29:08 +0100
committerPeter Eisentraut <peter@eisentraut.org>2024-03-20 10:05:37 +0100
commite5da0fe3c22b34c4433f1729e88495554b5331ed (patch)
treefa99ee64f20e482db38cf3c45d849510a9e7507a /src/backend/utils/adt/ruleutils.c
parentc9c260decd239159277c1baad9d929ebcdf2491e (diff)
downloadpostgresql-e5da0fe3c22b34c4433f1729e88495554b5331ed.tar.gz
postgresql-e5da0fe3c22b34c4433f1729e88495554b5331ed.zip
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
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r--src/backend/utils/adt/ruleutils.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 752757be116..07b454418d7 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -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;
}