diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-03-27 23:21:12 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-03-27 23:21:12 +0000 |
| commit | bf94076348ef7e0a81e3fe4ededb2fdcd14b303b (patch) | |
| tree | e513ac49a62f2fbde540bbc57b3e162d7ff13624 /src/backend/optimizer/path | |
| parent | 87564ffc6a87c6cdcc669472892be2ef0870a0f3 (diff) | |
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.
Diffstat (limited to 'src/backend/optimizer/path')
| -rw-r--r-- | src/backend/optimizer/path/costsize.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c index 3dbb3bd802d..ff5bb783372 100644 --- a/src/backend/optimizer/path/costsize.c +++ b/src/backend/optimizer/path/costsize.c @@ -54,7 +54,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.178 2007/02/22 22:00:24 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.179 2007/03/27 23:21:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1891,6 +1891,15 @@ cost_qual_eval_walker(Node *node, cost_qual_eval_context *context) context->total.per_tuple += get_func_cost(saop->opfuncid) * cpu_operator_cost * estimate_array_length(arraynode) * 0.5; } + else if (IsA(node, ArrayCoerceExpr)) + { + ArrayCoerceExpr *acoerce = (ArrayCoerceExpr *) node; + Node *arraynode = (Node *) acoerce->arg; + + if (OidIsValid(acoerce->elemfuncid)) + context->total.per_tuple += get_func_cost(acoerce->elemfuncid) * + cpu_operator_cost * estimate_array_length(arraynode); + } else if (IsA(node, RowCompareExpr)) { /* Conservatively assume we will check all the columns */ |
