1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-06 13:46:51 +03:00

Remove unnecessary code to handle CONSTR_NOTNULL

Commit 14e87ffa5c 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) <jian.universality@gmail.com>
Discussion: https://postgr.es/m/CACJufxFxzqrCiUNfjJ0tQU+=nKQkQCGtGzUBude=SMOwj5VNjQ@mail.gmail.com
This commit is contained in:
Álvaro Herrera
2025-01-07 16:49:41 +01:00
parent ec986020de
commit 5b291d1c9c
2 changed files with 11 additions and 17 deletions

View File

@@ -427,7 +427,7 @@ heap_create(const char *relname,
* 6) AddNewAttributeTuples() is called to register the * 6) AddNewAttributeTuples() is called to register the
* new relation's schema in pg_attribute. * 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 * 8) the relations are closed and the new relation's oid
* is returned. * is returned.
@@ -1481,7 +1481,7 @@ heap_create_with_catalog(const char *relname,
InvokeObjectPostCreateHookArg(RelationRelationId, relid, 0, is_internal); 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 * NB: this may do a CommandCounterIncrement and rebuild the relcache
* entry, so the relation must be valid and self-consistent at this point. * 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. * 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++; numchecks++;
break; 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: default:
elog(ERROR, "unrecognized constraint type: %d", elog(ERROR, "unrecognized constraint type: %d",
(int) con->contype); (int) con->contype);

View File

@@ -1007,9 +1007,9 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
} }
/* /*
* Create the relation. Inherited defaults and constraints are passed in * Create the relation. Inherited defaults and CHECK constraints are
* for immediate handling --- since they don't need parsing, they can be * passed in for immediate handling --- since they don't need parsing,
* stored immediately. * they can be stored immediately.
*/ */
relationId = heap_create_with_catalog(relname, relationId = heap_create_with_catalog(relname,
namespaceId, namespaceId,
@@ -2437,10 +2437,11 @@ storage_name(char c)
* 'is_partition' tells if the table is a partition. * 'is_partition' tells if the table is a partition.
* *
* Output arguments: * Output arguments:
* 'supconstr' receives a list of constraints belonging to the parents, * 'supconstr' receives a list of CookedConstraint representing
* updated as necessary to be valid for the child. * CHECK constraints belonging to parent relations, updated as
* 'supnotnulls' receives a list of CookedConstraints that corresponds to * necessary to be valid for the child.
* constraints coming from inheritance parents. * 'supnotnulls' receives a list of CookedConstraint representing
* not-null constraints based on those from parent relations.
* *
* Return value: * Return value:
* Completed schema list. * Completed schema list.