aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rowley <drowley@postgresql.org>2021-05-24 12:37:11 +1200
committerDavid Rowley <drowley@postgresql.org>2021-05-24 12:37:11 +1200
commit99c5852e20a0987eca1c38ba0c09329d4076b6a0 (patch)
treef3844537fe0f8b765cc741679941a22b21bdda38
parentf5024d8d7b04de2f5f4742ab433cc38160354861 (diff)
downloadpostgresql-99c5852e20a0987eca1c38ba0c09329d4076b6a0.tar.gz
postgresql-99c5852e20a0987eca1c38ba0c09329d4076b6a0.zip
Add missing NULL check when building Result Cache paths
Code added in 9e215378d to disable building of Result Cache paths when not all join conditions are part of the parameterization of a unique join failed to first check if the inner path's param_info was set before checking the param_info's ppi_clauses. Add a check for NULL values here and just bail on trying to build the path if param_info is NULL. lateral_vars are not considered when deciding if the join is unique, so we're not missing out on doing the optimization when there are lateral_vars and no param_info. Reported-by: Coverity, via Tom Lane Discussion: https://postgr.es/m/457998.1621779290@sss.pgh.pa.us
-rw-r--r--src/backend/optimizer/path/joinpath.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c
index d9d48827a9a..b67b5177707 100644
--- a/src/backend/optimizer/path/joinpath.c
+++ b/src/backend/optimizer/path/joinpath.c
@@ -530,8 +530,9 @@ get_resultcache_path(PlannerInfo *root, RelOptInfo *innerrel,
* considering doing that?
*/
if (extra->inner_unique &&
- list_length(inner_path->param_info->ppi_clauses) <
- list_length(extra->restrictlist))
+ (inner_path->param_info == NULL ||
+ list_length(inner_path->param_info->ppi_clauses) <
+ list_length(extra->restrictlist)))
return NULL;
/*