mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +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:
@@ -18,7 +18,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.302 2007/03/17 00:11:03 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.303 2007/03/27 23:21:09 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -359,6 +359,27 @@ _equalRelabelType(RelabelType *a, RelabelType *b)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalArrayCoerceExpr(ArrayCoerceExpr *a, ArrayCoerceExpr *b)
|
||||
{
|
||||
COMPARE_NODE_FIELD(arg);
|
||||
COMPARE_SCALAR_FIELD(elemfuncid);
|
||||
COMPARE_SCALAR_FIELD(resulttype);
|
||||
COMPARE_SCALAR_FIELD(resulttypmod);
|
||||
COMPARE_SCALAR_FIELD(isExplicit);
|
||||
|
||||
/*
|
||||
* Special-case COERCE_DONTCARE, so that planner can build coercion nodes
|
||||
* that are equal() to both explicit and implicit coercions.
|
||||
*/
|
||||
if (a->coerceformat != b->coerceformat &&
|
||||
a->coerceformat != COERCE_DONTCARE &&
|
||||
b->coerceformat != COERCE_DONTCARE)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalConvertRowtypeExpr(ConvertRowtypeExpr *a, ConvertRowtypeExpr *b)
|
||||
{
|
||||
@@ -2013,6 +2034,9 @@ equal(void *a, void *b)
|
||||
case T_RelabelType:
|
||||
retval = _equalRelabelType(a, b);
|
||||
break;
|
||||
case T_ArrayCoerceExpr:
|
||||
retval = _equalArrayCoerceExpr(a, b);
|
||||
break;
|
||||
case T_ConvertRowtypeExpr:
|
||||
retval = _equalConvertRowtypeExpr(a, b);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user