diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-03-16 00:31:55 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-03-16 00:31:55 +0000 |
commit | 23160139617f6cb998604c7324da2175f7409db5 (patch) | |
tree | cdd877b18be4f800499f4240c76aaed7759e0a2f /src/backend/access/common/tupdesc.c | |
parent | 5981b9d03e724a54f3eac706c27056d601954a7f (diff) | |
download | postgresql-23160139617f6cb998604c7324da2175f7409db5.tar.gz postgresql-23160139617f6cb998604c7324da2175f7409db5.zip |
Clean up representation of function RTEs for functions returning RECORD.
The original coding stored the raw parser output (ColumnDef and TypeName
nodes) which was ugly, bulky, and wrong because it failed to create any
dependency on the referenced datatype --- and in fact would not track type
renamings and suchlike. Instead store a list of column type OIDs in the
RTE.
Also fix up general failure of recordDependencyOnExpr to do anything sane
about recording dependencies on datatypes. While there are many cases where
there will be an indirect dependency (eg if an operator returns a datatype,
the dependency on the operator is enough), we do have to record the datatype
as a separate dependency in examples like CoerceToDomain.
initdb forced because of change of stored rules.
Diffstat (limited to 'src/backend/access/common/tupdesc.c')
-rw-r--r-- | src/backend/access/common/tupdesc.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c index 8726797524b..020011966f0 100644 --- a/src/backend/access/common/tupdesc.c +++ b/src/backend/access/common/tupdesc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/common/tupdesc.c,v 1.115 2006/03/14 22:48:18 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/common/tupdesc.c,v 1.116 2006/03/16 00:31:54 tgl Exp $ * * NOTES * some of the executor utility code such as "ExecTypeFromTL" should be @@ -554,3 +554,54 @@ BuildDescForRelation(List *schema) return desc; } + +/* + * BuildDescFromLists + * + * Build a TupleDesc given lists of column names (as String nodes), + * column type OIDs, and column typmods. No constraints are generated. + * + * This is essentially a cut-down version of BuildDescForRelation for use + * with functions returning RECORD. + */ +TupleDesc +BuildDescFromLists(List *names, List *types, List *typmods) +{ + int natts; + AttrNumber attnum; + ListCell *l1; + ListCell *l2; + ListCell *l3; + TupleDesc desc; + + natts = list_length(names); + Assert(natts == list_length(types)); + Assert(natts == list_length(typmods)); + + /* + * allocate a new tuple descriptor + */ + desc = CreateTemplateTupleDesc(natts, false); + + attnum = 0; + + l2 = list_head(types); + l3 = list_head(typmods); + foreach(l1, names) + { + char *attname = strVal(lfirst(l1)); + Oid atttypid; + int32 atttypmod; + + atttypid = lfirst_oid(l2); + l2 = lnext(l2); + atttypmod = lfirst_int(l3); + l3 = lnext(l3); + + attnum++; + + TupleDescInitEntry(desc, attnum, attname, atttypid, atttypmod, 0); + } + + return desc; +} |