cost_tidrangescan() was setting the disabled_nodes value correctly,
and then immediately resetting it to zero, due to poor code editing on
my part.
materialized_finished_plan correctly set matpath.parent to
zero, but forgot to also set matpath.parallel_workers = 0, causing
an access to uninitialized memory in cost_material. (This shouldn't
result in any real problem, but it makes valgrind unhappy.)
reparameterize_path was dereferencing a variable before verifying that
it was not NULL.
Reported-by: Tom Lane <tgl@sss.pgh.pa.us> (issue #1)
Reported-by: Michael Paquier <michael@paquier.xyz> (issue #1)
Diagnosed-by: Lukas Fittl <lukas@fittl.com> (issue #1)
Reported-by: Zsolt Parragi <zsolt.parragi@percona.com> (issue #2)
Reported-by: Richard Guo <guofenglinux@gmail.com> (issue #3)
Discussion: http://postgr.es/m/CAN4CZFPvwjNJEZ_JT9Y67yR7C=KMNa=LNefOB8ZY7TKDcmAXOA@mail.gmail.com
Discussion: http://postgr.es/m/aXrnPgrq6Gggb5TG@paquier.xyz
enable_mask |= PGS_CONSIDER_NONPARTIAL;
path->disabled_nodes =
(baserel->pgs_mask & enable_mask) != enable_mask ? 1 : 0;
- path->disabled_nodes = 0;
path->startup_cost = startup_cost;
path->total_cost = startup_cost + cpu_run_cost + disk_run_cost;
}
subplan->startup_cost -= initplan_cost;
subplan->total_cost -= initplan_cost;
- /* Set cost data */
+ /* Clear fields that cost_material() will consult */
+ matpath.parallel_workers = 0;
matpath.parent = NULL;
+
+ /* Set cost data */
cost_material(&matpath,
enable_material,
subplan->disabled_nodes,
spath = reparameterize_path(root, spath,
required_outer,
loop_count);
- enabled =
- (mpath->path.disabled_nodes <= spath->disabled_nodes);
if (spath == NULL)
return NULL;
+ enabled =
+ (mpath->path.disabled_nodes <= spath->disabled_nodes);
return (Path *) create_material_path(rel, spath, enabled);
}
case T_Memoize: