mirror of
https://github.com/postgres/postgres.git
synced 2025-08-14 02:22:38 +03:00
Fix array coercion expressions to ensure that the correct volatility is
seen by code inspecting the expression. The best way to do this seems to be to drop the original representation as a function invocation, and instead make a special expression node type that represents applying the element-type coercion function to each array element. In this way the element function is exposed and will be checked for volatility. Per report from Guillaume Smet.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.256 2007/03/18 16:50:42 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.257 2007/03/27 23:21:10 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -3123,6 +3123,9 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags)
|
||||
case T_RelabelType:
|
||||
return isSimpleNode((Node *) ((RelabelType *) node)->arg,
|
||||
node, prettyFlags);
|
||||
case T_ArrayCoerceExpr:
|
||||
return isSimpleNode((Node *) ((ArrayCoerceExpr *) node)->arg,
|
||||
node, prettyFlags);
|
||||
case T_ConvertRowtypeExpr:
|
||||
return isSimpleNode((Node *) ((ConvertRowtypeExpr *) node)->arg,
|
||||
node, prettyFlags);
|
||||
@@ -3588,6 +3591,27 @@ get_rule_expr(Node *node, deparse_context *context,
|
||||
}
|
||||
break;
|
||||
|
||||
case T_ArrayCoerceExpr:
|
||||
{
|
||||
ArrayCoerceExpr *acoerce = (ArrayCoerceExpr *) node;
|
||||
Node *arg = (Node *) acoerce->arg;
|
||||
|
||||
if (acoerce->coerceformat == COERCE_IMPLICIT_CAST &&
|
||||
!showimplicit)
|
||||
{
|
||||
/* don't show the implicit cast */
|
||||
get_rule_expr_paren(arg, context, false, node);
|
||||
}
|
||||
else
|
||||
{
|
||||
get_coercion_expr(arg, context,
|
||||
acoerce->resulttype,
|
||||
acoerce->resulttypmod,
|
||||
node);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case T_ConvertRowtypeExpr:
|
||||
{
|
||||
ConvertRowtypeExpr *convert = (ConvertRowtypeExpr *) node;
|
||||
|
Reference in New Issue
Block a user