Fix unwarranted assumption that a cached rowtype would stick around
authorTom Lane
Wed, 3 Feb 2010 05:46:37 +0000 (05:46 +0000)
committerTom Lane
Wed, 3 Feb 2010 05:46:37 +0000 (05:46 +0000)
for the lifespan of the CreateStmt.  Per buildfarm member jaguar.

src/backend/parser/parse_utilcmd.c

index bf455701e33309a261fa43b10ba593113055a14b..f2b29d327c7a7df2483d034ea895e40311a00a7e 100644 (file)
@@ -19,7 +19,7 @@
  * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.37 2010/01/28 23:21:12 petere Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.38 2010/02/03 05:46:37 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -822,10 +822,10 @@ transformOfType(ParseState *pstate, CreateStmtContext *cxt, TypeName *ofTypename
    tupdesc = lookup_rowtype_tupdesc(ofTypeId, -1);
    for (i = 0; i < tupdesc->natts; i++)
    {
-       ColumnDef *n = makeNode(ColumnDef);
        Form_pg_attribute attr = tupdesc->attrs[i];
+       ColumnDef *n = makeNode(ColumnDef);
 
-       n->colname = NameStr(attr->attname);
+       n->colname = pstrdup(NameStr(attr->attname));
        n->typeName = makeTypeNameFromOid(attr->atttypid, attr->atttypmod);
        n->constraints = NULL;
        n->is_local = true;