git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1345cc6)
Need to special-case RECORD as well as UNKNOWN in plpgsql's casting logic.
Thu, 5 Mar 2015 00:10:57 +0000 (19:10 -0500)
Thu, 5 Mar 2015 00:10:57 +0000 (19:10 -0500)
This is because can_coerce_type thinks that RECORD can be cast to any
composite type, but coerce_record_to_complex only works for inputs that are
RowExprs or whole-row Vars, so we get a hard failure on a CaseTestExpr.

Perhaps these corner cases ought to be fixed so that coerce_to_target_type
actually returns NULL as per its specification, rather than failing ...
but for the moment an extra check here is the path of least resistance.


diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 4030b647fb029ab30cb560753f387750c921905d..315d28b8fae8e6cac9efb7b9af94fb82e3b19b89 100644 (file)
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -5829,17 +5829,18 @@ get_cast_expression(PLpgSQL_execstate *estate,
*
* If source type is UNKNOWN, coerce_to_target_type will fail (it only
* expects to see that for Const input nodes), so don't call it; we'll
- * apply CoerceViaIO instead.
+ * apply CoerceViaIO instead. Likewise, it doesn't currently work for
+ * coercing RECORD to some other type, so skip for that too.
*/
- if (srctype != UNKNOWNOID)
+ if (srctype == UNKNOWNOID || srctype == RECORDOID)
+ cast_expr = NULL;
+ else
cast_expr = coerce_to_target_type(NULL,
(Node *) placeholder, srctype,
dsttype, dsttypmod,
COERCION_ASSIGNMENT,
COERCE_IMPLICIT_CAST,
-1);
- else
- cast_expr = NULL;
/*
* If there's no cast path according to the parser, fall back to using an
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /