Commit d468e19a authored by Tom Lane's avatar Tom Lane

Allow implicit cast from any named composite type to RECORD. At the

moment this has no particular use except to allow table rows to be
passed to record_out(), but that case seems to be useful in itself
per recent example from Elein.  Further down the road we could look
at letting PL functions be declared to accept RECORD parameters.
parent 13f75e37
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.127 2005/03/29 00:17:04 tgl Exp $ * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.128 2005/05/05 00:19:47 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -318,6 +318,13 @@ coerce_type(ParseState *pstate, Node *node, ...@@ -318,6 +318,13 @@ coerce_type(ParseState *pstate, Node *node,
return coerce_record_to_complex(pstate, node, targetTypeId, return coerce_record_to_complex(pstate, node, targetTypeId,
ccontext, cformat); ccontext, cformat);
} }
if (targetTypeId == RECORDOID &&
ISCOMPLEX(inputTypeId))
{
/* Coerce a specific complex type to RECORD */
/* NB: we do NOT want a RelabelType here */
return node;
}
if (typeInheritsFrom(inputTypeId, targetTypeId)) if (typeInheritsFrom(inputTypeId, targetTypeId))
{ {
/* /*
...@@ -405,6 +412,13 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids, ...@@ -405,6 +412,13 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids,
ISCOMPLEX(targetTypeId)) ISCOMPLEX(targetTypeId))
continue; continue;
/*
* If input is a composite type and target is RECORD, accept
*/
if (targetTypeId == RECORDOID &&
ISCOMPLEX(inputTypeId))
continue;
/* /*
* If input is a class type that inherits from target, accept * If input is a class type that inherits from target, accept
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment