Thread: Invalid Path with UpperRel

Invalid Path with UpperRel

From
Alena Rybakina
Date:

Hi, hackers!

I recently encountered strange behavior when, after running the create_ms.sql test, I ran the last query from this test. In general, the playback looks like this:

\i src/test/regress/sql/create_misc.sql

I added Assert(0) in create_sort_plan() before calling create_plan_recurse and restarted postgres. After that I run query:
SELECT relname, reltoastrelid <> 0 AS has_toast_table
   FROM pg_class
   WHERE oid::regclass IN ('a_star', 'c_star')
   ORDER BY 1;

I found Invalid_path in cheapest_startup_path:

 (gdb) p *(IndexPath *)((SortPath *)best_path)->subpath->parent->cheapest_startup_path
$12 = {path = {type = T_Invalid, pathtype = T_Invalid, parent = 0x7f7f7f7f7f7f7f7f, pathtarget = 0x7f7f7f7f7f7f7f7f, param_info = 0x7f7f7f7f7f7f7f7f,
    parallel_aware = 127, parallel_safe = 127, parallel_workers = 2139062143, rows = 1.3824172084878715e+306, startup_cost = 1.3824172084878715e+306,
    total_cost = 1.3824172084878715e+306, pathkeys = 0x7f7f7f7f7f7f7f7f}, indexinfo = 0x7f7f7f7f7f7f7f7f, indexclauses = 0x7f7f7f7f7f7f7f7f,
  indexorderbys = 0x7f7f7f7f7f7f7f7f, indexorderbycols = 0x7f7f7f7f7f7f7f7f, indexscandir = 2139062143, indextotalcost = 1.3824172084878715e+306,
  indexselectivity = 1.3824172084878715e+306}

(gdb) p (IndexPath *)((SortPath *)best_path)->subpath->parent->cheapest_startup_path
$11 = (IndexPath *) 0x555febc66160

I found that this beginning since creation upperrel (fetch_upper_rel function):

/* primary planning entry point (may recurse for subqueries) */  root = subquery_planner(glob, parse, NULL,        false, tuple_fraction);  /* Select best Path and turn it into a Plan */  final_rel = fetch_upper_rel(root, UPPERREL_FINAL, NULL);  best_path = get_cheapest_fractional_path(final_rel, tuple_fraction);
Red Heart

(gdb) p *(IndexPath *)((SortPath *)final_rel->cheapest_total_path )->subpath->parent->cheapest_startup_path
$15 = {path = {type = T_Invalid, pathtype = T_Invalid, parent = 0x7f7f7f7f7f7f7f7f, pathtarget = 0x7f7f7f7f7f7f7f7f, param_info = 0x7f7f7f7f7f7f7f7f,
    parallel_aware = 127, parallel_safe = 127, parallel_workers = 2139062143, rows = 1.3824172084878715e+306, startup_cost = 1.3824172084878715e+306,
    total_cost = 1.3824172084878715e+306, pathkeys = 0x7f7f7f7f7f7f7f7f}, indexinfo = 0x7f7f7f7f7f7f7f7f, indexclauses = 0x7f7f7f7f7f7f7f7f,
  indexorderbys = 0x7f7f7f7f7f7f7f7f, indexorderbycols = 0x7f7f7f7f7f7f7f7f, indexscandir = 2139062143, indextotalcost = 1.3824172084878715e+306,
  indexselectivity = 1.3824172084878715e+306}
(gdb) p (IndexPath *)((SortPath *)final_rel->cheapest_total_path )->subpath->parent->cheapest_startup_path
$16 = (IndexPath *) 0x555febc66160
I know it doesn't cause a crash anywhere, but can anybody explain me what's going on here and why Invalid Path appears?

-- 
Regards,
Alena Rybakina