aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-05-05 00:19:47 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-05-05 00:19:47 +0000
commitd468e19a061da518d99c068527a537b90a5f3abd (patch)
tree109a1123a563d8522932e192dd09c73035dc2500
parent13f75e378ef07c1d61780a29ae17ac4fd607cda5 (diff)
downloadpostgresql-d468e19a061da518d99c068527a537b90a5f3abd.tar.gz
postgresql-d468e19a061da518d99c068527a537b90a5f3abd.zip
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.
-rw-r--r--src/backend/parser/parse_coerce.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index 32455785a46..287e496570b 100644
--- a/src/backend/parser/parse_coerce.c
+++ b/src/backend/parser/parse_coerce.c
@@ -8,7 +8,7 @@
*
*
* 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,
return coerce_record_to_complex(pstate, node, targetTypeId,
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))
{
/*
@@ -406,6 +413,13 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids,
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 (typeInheritsFrom(inputTypeId, targetTypeId))