Skip to content

Commit 45f2c2f

Browse files
committed
Need to special-case RECORD as well as UNKNOWN in plpgsql's casting logic.
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.
1 parent 1345cc6 commit 45f2c2f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/pl/plpgsql/src/pl_exec.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5829,17 +5829,18 @@ get_cast_expression(PLpgSQL_execstate *estate,
58295829
*
58305830
* If source type is UNKNOWN, coerce_to_target_type will fail (it only
58315831
* expects to see that for Const input nodes), so don't call it; we'll
5832-
* apply CoerceViaIO instead.
5832+
* apply CoerceViaIO instead. Likewise, it doesn't currently work for
5833+
* coercing RECORD to some other type, so skip for that too.
58335834
*/
5834-
if (srctype != UNKNOWNOID)
5835+
if (srctype == UNKNOWNOID || srctype == RECORDOID)
5836+
cast_expr = NULL;
5837+
else
58355838
cast_expr = coerce_to_target_type(NULL,
58365839
(Node *) placeholder, srctype,
58375840
dsttype, dsttypmod,
58385841
COERCION_ASSIGNMENT,
58395842
COERCE_IMPLICIT_CAST,
58405843
-1);
5841-
else
5842-
cast_expr = NULL;
58435844

58445845
/*
58455846
* If there's no cast path according to the parser, fall back to using an

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy