Skip to content

Commit 5b291d1

Browse files
committed
Remove unnecessary code to handle CONSTR_NOTNULL
Commit 14e87ff 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
1 parent ec98602 commit 5b291d1

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

src/backend/catalog/heap.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ heap_create(const char *relname,
427427
* 6) AddNewAttributeTuples() is called to register the
428428
* new relation's schema in pg_attribute.
429429
*
430-
* 7) StoreConstraints is called () - vadim 08/22/97
430+
* 7) StoreConstraints() is called - vadim 08/22/97
431431
*
432432
* 8) the relations are closed and the new relation's oid
433433
* is returned.
@@ -1481,7 +1481,7 @@ heap_create_with_catalog(const char *relname,
14811481
InvokeObjectPostCreateHookArg(RelationRelationId, relid, 0, is_internal);
14821482

14831483
/*
1484-
* Store any supplied constraints and defaults.
1484+
* Store any supplied CHECK constraints and defaults.
14851485
*
14861486
* NB: this may do a CommandCounterIncrement and rebuild the relcache
14871487
* 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,
22162216
}
22172217

22182218
/*
2219-
* Store defaults and constraints (passed as a list of CookedConstraint).
2219+
* Store defaults and CHECK constraints (passed as a list of CookedConstraint).
22202220
*
22212221
* Each CookedConstraint struct is modified to store the new catalog tuple OID.
22222222
*
@@ -2260,13 +2260,6 @@ StoreConstraints(Relation rel, List *cooked_constraints, bool is_internal)
22602260
numchecks++;
22612261
break;
22622262

2263-
case CONSTR_NOTNULL:
2264-
con->conoid =
2265-
StoreRelNotNull(rel, con->name, con->attnum,
2266-
!con->skip_validation, con->is_local,
2267-
con->inhcount, con->is_no_inherit);
2268-
break;
2269-
22702263
default:
22712264
elog(ERROR, "unrecognized constraint type: %d",
22722265
(int) con->contype);

src/backend/commands/tablecmds.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,9 +1007,9 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
10071007
}
10081008

10091009
/*
1010-
* Create the relation. Inherited defaults and constraints are passed in
1011-
* for immediate handling --- since they don't need parsing, they can be
1012-
* stored immediately.
1010+
* Create the relation. Inherited defaults and CHECK constraints are
1011+
* passed in for immediate handling --- since they don't need parsing,
1012+
* they can be stored immediately.
10131013
*/
10141014
relationId = heap_create_with_catalog(relname,
10151015
namespaceId,
@@ -2437,10 +2437,11 @@ storage_name(char c)
24372437
* 'is_partition' tells if the table is a partition.
24382438
*
24392439
* Output arguments:
2440-
* 'supconstr' receives a list of constraints belonging to the parents,
2441-
* updated as necessary to be valid for the child.
2442-
* 'supnotnulls' receives a list of CookedConstraints that corresponds to
2443-
* constraints coming from inheritance parents.
2440+
* 'supconstr' receives a list of CookedConstraint representing
2441+
* CHECK constraints belonging to parent relations, updated as
2442+
* necessary to be valid for the child.
2443+
* 'supnotnulls' receives a list of CookedConstraint representing
2444+
* not-null constraints based on those from parent relations.
24442445
*
24452446
* Return value:
24462447
* Completed schema list.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy