mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Add SQL Standard WITH ORDINALITY support for UNNEST (and any other SRF)
Author: Andrew Gierth, David Fetter Reviewers: Dean Rasheed, Jeevan Chalke, Stephen Frost
This commit is contained in:
@@ -157,6 +157,40 @@ CreateTupleDescCopy(TupleDesc tupdesc)
|
||||
return desc;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
||||
Reference in New Issue
Block a user