Skip to content

Commit d468e19

Browse files
committed
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.
1 parent 13f75e3 commit d468e19

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/backend/parser/parse_coerce.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.127 2005/03/29 00:17:04 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.128 2005/05/05 00:19:47 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -318,6 +318,13 @@ coerce_type(ParseState *pstate, Node *node,
318318
return coerce_record_to_complex(pstate, node, targetTypeId,
319319
ccontext, cformat);
320320
}
321+
if (targetTypeId == RECORDOID &&
322+
ISCOMPLEX(inputTypeId))
323+
{
324+
/* Coerce a specific complex type to RECORD */
325+
/* NB: we do NOT want a RelabelType here */
326+
return node;
327+
}
321328
if (typeInheritsFrom(inputTypeId, targetTypeId))
322329
{
323330
/*
@@ -405,6 +412,13 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids,
405412
ISCOMPLEX(targetTypeId))
406413
continue;
407414

415+
/*
416+
* If input is a composite type and target is RECORD, accept
417+
*/
418+
if (targetTypeId == RECORDOID &&
419+
ISCOMPLEX(inputTypeId))
420+
continue;
421+
408422
/*
409423
* If input is a class type that inherits from target, accept
410424
*/

0 commit comments

Comments
 (0)