summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÁlvaro Herrera2025-01-07 15:49:41 +0000
committerÁlvaro Herrera2025-01-07 15:49:41 +0000
commit5b291d1c9c09d75982c3270bfa61d4e822087b6a (patch)
tree5d6e6c908e7abe646588d5e212ba431b4885515c
parentec986020decff322723cf7b3a2696803d082ad17 (diff)
Remove unnecessary code to handle CONSTR_NOTNULL
Commit 14e87ffa5c54 needlessly added support for CONSTR_NOTNULL entries to StoreConstraints. It's dead code, so remove it. To make the situation regarding constraint creation clearer, change comments in heap_create_with_catalog, StoreConstraints, MergeAttributes to explain which types of constraint are used on each. Author: 何建 (Jian He) <[email protected]> Discussion: https://postgr.es/m/CACJufxFxzqrCiUNfjJ0tQU+=nKQkQCGtGzUBude=SMOwj5VNjQ@mail.gmail.com
-rw-r--r--src/backend/catalog/heap.c13
-rw-r--r--src/backend/commands/tablecmds.c15
2 files changed, 11 insertions, 17 deletions
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 4d760c98d1..024521c66c 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -427,7 +427,7 @@ heap_create(const char *relname,
* 6) AddNewAttributeTuples() is called to register the
* new relation's schema in pg_attribute.
*
- * 7) StoreConstraints is called () - vadim 08/22/97
+ * 7) StoreConstraints() is called - vadim 08/22/97
*
* 8) the relations are closed and the new relation's oid
* is returned.
@@ -1481,7 +1481,7 @@ heap_create_with_catalog(const char *relname,
InvokeObjectPostCreateHookArg(RelationRelationId, relid, 0, is_internal);
/*
- * Store any supplied constraints and defaults.
+ * Store any supplied CHECK constraints and defaults.
*
* NB: this may do a CommandCounterIncrement and rebuild the relcache
* entry, so the relation must be valid and self-consistent at this point.
@@ -2216,7 +2216,7 @@ StoreRelNotNull(Relation rel, const char *nnname, AttrNumber attnum,
}
/*
- * Store defaults and constraints (passed as a list of CookedConstraint).
+ * Store defaults and CHECK constraints (passed as a list of CookedConstraint).
*
* Each CookedConstraint struct is modified to store the new catalog tuple OID.
*
@@ -2260,13 +2260,6 @@ StoreConstraints(Relation rel, List *cooked_constraints, bool is_internal)
numchecks++;
break;
- case CONSTR_NOTNULL:
- con->conoid =
- StoreRelNotNull(rel, con->name, con->attnum,
- !con->skip_validation, con->is_local,
- con->inhcount, con->is_no_inherit);
- break;
-
default:
elog(ERROR, "unrecognized constraint type: %d",
(int) con->contype);
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 33ea619224..4181c110eb 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -1007,9 +1007,9 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
}
/*
- * Create the relation. Inherited defaults and constraints are passed in
- * for immediate handling --- since they don't need parsing, they can be
- * stored immediately.
+ * Create the relation. Inherited defaults and CHECK constraints are
+ * passed in for immediate handling --- since they don't need parsing,
+ * they can be stored immediately.
*/
relationId = heap_create_with_catalog(relname,
namespaceId,
@@ -2437,10 +2437,11 @@ storage_name(char c)
* 'is_partition' tells if the table is a partition.
*
* Output arguments:
- * 'supconstr' receives a list of constraints belonging to the parents,
- * updated as necessary to be valid for the child.
- * 'supnotnulls' receives a list of CookedConstraints that corresponds to
- * constraints coming from inheritance parents.
+ * 'supconstr' receives a list of CookedConstraint representing
+ * CHECK constraints belonging to parent relations, updated as
+ * necessary to be valid for the child.
+ * 'supnotnulls' receives a list of CookedConstraint representing
+ * not-null constraints based on those from parent relations.
*
* Return value:
* Completed schema list.