aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2024-07-01 08:50:29 +0200
committerPeter Eisentraut <peter@eisentraut.org>2024-07-01 08:50:29 +0200
commite26d313bad92e71e2b59cc2e81870bf6d750de1f (patch)
tree33aa11ee33ee8885a877aceeb67d1f49dc6f1ebf
parentda2aeba8f53379e84a8f3f656b6c2ffe5878eff5 (diff)
downloadpostgresql-e26d313bad92e71e2b59cc2e81870bf6d750de1f.tar.gz
postgresql-e26d313bad92e71e2b59cc2e81870bf6d750de1f.zip
Remove useless code
BuildDescForRelation() goes out of its way to fill in ->constr->has_not_null, but that value is not used for anything later, so this code can all be removed. Note that BuildDescForRelation() doesn't make any effort to fill in the rest of ->constr, so there is no claim that that structure is completely filled in. Reviewed-by: Tomasz Rybak <tomasz.rybak@post.pl> Discussion: https://www.postgresql.org/message-id/flat/a368248e-69e4-40be-9c07-6c3b5880b0a6@eisentraut.org
-rw-r--r--src/backend/commands/tablecmds.c25
1 files changed, 3 insertions, 22 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 8fcb1883234..9e9dc5c2c13 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -1273,7 +1273,9 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
*
* Given a list of ColumnDef nodes, build a TupleDesc.
*
- * Note: tdtypeid will need to be filled in later on.
+ * Note: This is only for the limited purpose of table and view creation. Not
+ * everything is filled in. A real tuple descriptor should be obtained from
+ * the relcache.
*/
TupleDesc
BuildDescForRelation(const List *columns)
@@ -1282,7 +1284,6 @@ BuildDescForRelation(const List *columns)
AttrNumber attnum;
ListCell *l;
TupleDesc desc;
- bool has_not_null;
char *attname;
Oid atttypid;
int32 atttypmod;
@@ -1294,7 +1295,6 @@ BuildDescForRelation(const List *columns)
*/
natts = list_length(columns);
desc = CreateTemplateTupleDesc(natts);
- has_not_null = false;
attnum = 0;
@@ -1340,7 +1340,6 @@ BuildDescForRelation(const List *columns)
/* Fill in additional stuff not handled by TupleDescInitEntry */
att->attnotnull = entry->is_not_null;
- has_not_null |= entry->is_not_null;
att->attislocal = entry->is_local;
att->attinhcount = entry->inhcount;
att->attidentity = entry->identity;
@@ -1352,24 +1351,6 @@ BuildDescForRelation(const List *columns)
att->attstorage = GetAttributeStorage(att->atttypid, entry->storage_name);
}
- if (has_not_null)
- {
- TupleConstr *constr = (TupleConstr *) palloc0(sizeof(TupleConstr));
-
- constr->has_not_null = true;
- constr->has_generated_stored = false;
- constr->defval = NULL;
- constr->missing = NULL;
- constr->num_defval = 0;
- constr->check = NULL;
- constr->num_check = 0;
- desc->constr = constr;
- }
- else
- {
- desc->constr = NULL;
- }
-
return desc;
}