diff options
author | Greg Stark <stark@mit.edu> | 2013-07-29 16:38:01 +0100 |
---|---|---|
committer | Greg Stark <stark@mit.edu> | 2013-07-29 16:38:01 +0100 |
commit | c62736cc37f6812d1ebb41ea5a86ffe60564a1f0 (patch) | |
tree | 3cb1654476a7e45620d9a3320a002495d000380e /src/backend/access/common/tupdesc.c | |
parent | 55cbfa5366b78d93cd1ff8c4c622b552985344f6 (diff) |
Add SQL Standard WITH ORDINALITY support for UNNEST (and any other SRF)
Author: Andrew Gierth, David Fetter
Reviewers: Dean Rasheed, Jeevan Chalke, Stephen Frost
Diffstat (limited to 'src/backend/access/common/tupdesc.c')
-rw-r--r-- | src/backend/access/common/tupdesc.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c index fb5c199c0c4..11c31d8fe92 100644 --- a/src/backend/access/common/tupdesc.c +++ b/src/backend/access/common/tupdesc.c @@ -158,6 +158,40 @@ CreateTupleDescCopy(TupleDesc tupdesc) } /* + * CreateTupleDescCopyExtend + * This function creates a new TupleDesc by copying from an existing + * TupleDesc, but adding space for more columns. The new tupdesc is + * not regarded as the same record type as the old one (and therefore + * does not inherit its typeid/typmod, which instead are left as an + * anonymous record type). + * + * The additional column slots are not initialized in any way; + * callers must do their own TupleDescInitEntry on each. + * + * !!! Constraints and defaults are not copied !!! + */ +TupleDesc +CreateTupleDescCopyExtend(TupleDesc tupdesc, int moreatts) +{ + TupleDesc desc; + int i; + int src_natts = tupdesc->natts; + + Assert(moreatts >= 0); + + desc = CreateTemplateTupleDesc(src_natts + moreatts, tupdesc->tdhasoid); + + for (i = 0; i < src_natts; i++) + { + memcpy(desc->attrs[i], tupdesc->attrs[i], ATTRIBUTE_FIXED_PART_SIZE); + desc->attrs[i]->attnotnull = false; + desc->attrs[i]->atthasdef = false; + } + + return desc; +} + +/* * CreateTupleDescCopyConstr * This function creates a new TupleDesc by copying from an existing * TupleDesc (including its constraints and defaults). |