aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_utilcmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/parser/parse_utilcmd.c')
-rw-r--r--src/backend/parser/parse_utilcmd.c40
1 files changed, 9 insertions, 31 deletions
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index bab7b87fe86..55c315f0e28 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -1066,7 +1066,6 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
{
Form_pg_attribute attribute = TupleDescAttr(tupleDesc,
parent_attno - 1);
- char *attributeName = NameStr(attribute->attname);
ColumnDef *def;
/*
@@ -1076,29 +1075,18 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
continue;
/*
- * Create a new column, which is marked as NOT inherited.
- *
+ * Create a new column definition
+ */
+ def = makeColumnDef(NameStr(attribute->attname), attribute->atttypid,
+ attribute->atttypmod, attribute->attcollation);
+
+ /*
* For constraints, ONLY the not-null constraint is inherited by the
* new column definition per SQL99; however we cannot do that
* correctly here, so we leave it for expandTableLikeClause to handle.
*/
- def = makeNode(ColumnDef);
- def->colname = pstrdup(attributeName);
- def->typeName = makeTypeNameFromOid(attribute->atttypid,
- attribute->atttypmod);
- def->inhcount = 0;
- def->is_local = true;
- def->is_not_null = false;
if (attribute->attnotnull)
process_notnull_constraints = true;
- def->is_from_type = false;
- def->storage = 0;
- def->raw_default = NULL;
- def->cooked_default = NULL;
- def->collClause = NULL;
- def->collOid = attribute->attcollation;
- def->constraints = NIL;
- def->location = -1;
/*
* Add to column list
@@ -1635,20 +1623,10 @@ transformOfType(CreateStmtContext *cxt, TypeName *ofTypename)
if (attr->attisdropped)
continue;
- n = makeNode(ColumnDef);
- n->colname = pstrdup(NameStr(attr->attname));
- n->typeName = makeTypeNameFromOid(attr->atttypid, attr->atttypmod);
- n->inhcount = 0;
- n->is_local = true;
- n->is_not_null = false;
+ n = makeColumnDef(NameStr(attr->attname), attr->atttypid,
+ attr->atttypmod, attr->attcollation);
n->is_from_type = true;
- n->storage = 0;
- n->raw_default = NULL;
- n->cooked_default = NULL;
- n->collClause = NULL;
- n->collOid = attr->attcollation;
- n->constraints = NIL;
- n->location = -1;
+
cxt->columns = lappend(cxt->columns, n);
}
ReleaseTupleDesc(tupdesc);