From bf94076348ef7e0a81e3fe4ededb2fdcd14b303b Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 27 Mar 2007 23:21:12 +0000 Subject: 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. --- src/backend/parser/parse_func.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/backend/parser/parse_func.c') diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index 888dc200d1f..01593317b1f 100644 --- a/src/backend/parser/parse_func.c +++ b/src/backend/parser/parse_func.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.194 2007/02/01 19:10:27 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.195 2007/03/27 23:21:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -756,13 +756,15 @@ func_get_detail(List *funcname, Oid sourceType = argtypes[0]; Node *arg1 = linitial(fargs); Oid cfuncid; + bool arrayCoerce; if ((sourceType == UNKNOWNOID && IsA(arg1, Const)) || (find_coercion_pathway(targetType, sourceType, - COERCION_EXPLICIT, &cfuncid) && - cfuncid == InvalidOid)) + COERCION_EXPLICIT, + &cfuncid, &arrayCoerce) && + cfuncid == InvalidOid && !arrayCoerce)) { - /* Yup, it's a type coercion */ + /* Yup, it's a trivial type coercion */ *funcid = InvalidOid; *rettype = targetType; *retset = false; -- cgit v1.2.3