1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-16 06:01:02 +03:00

Allow RECORD and RECORD[] to be specified in function coldeflists.

We can't allow these pseudo-types to be used as table column types,
because storing an anonymous record value in a table would result
in data that couldn't be understood by other sessions.  However,
it seems like there's no harm in allowing the case in a column
definition list that's specifying what a function-returning-record
returns.  The data involved is all local to the current session,
so we should be just as able to resolve its actual tuple type as
we are for the function-returning-record's top-level tuple output.

Elvis Pranskevichus, with cosmetic changes by me

Discussion: https://postgr.es/m/11038447.kQ5A9Uj5xi@hammer.magicstack.net
This commit is contained in:
Tom Lane
2019-01-30 19:25:33 -05:00
parent 689d15e95e
commit 5f5c014590
7 changed files with 70 additions and 19 deletions

View File

@ -1590,9 +1590,15 @@ addRangeTableEntryForFunction(ParseState *pstate,
/*
* Ensure that the coldeflist defines a legal set of names (no
* duplicates) and datatypes (no pseudo-types, for instance).
* duplicates, but we needn't worry about system column names) and
* datatypes. Although we mostly can't allow pseudo-types, it
* seems safe to allow RECORD and RECORD[], since values within
* those type classes are self-identifying at runtime, and the
* coldeflist doesn't represent anything that will be visible to
* other sessions.
*/
CheckAttributeNamesTypes(tupdesc, RELKIND_COMPOSITE_TYPE, false);
CheckAttributeNamesTypes(tupdesc, RELKIND_COMPOSITE_TYPE,
CHKATYPE_ANYRECORD);
}
else
ereport(ERROR,