diff --git a/src/backend/distributed/planner/multi_physical_planner.c b/src/backend/distributed/planner/multi_physical_planner.c index 16f888c82..c3cc73afd 100644 --- a/src/backend/distributed/planner/multi_physical_planner.c +++ b/src/backend/distributed/planner/multi_physical_planner.c @@ -1515,7 +1515,6 @@ UpdateColumnAttributes(Var *column, List *rangeTableList, List *dependedJobList) static Index NewTableId(Index originalTableId, List *rangeTableList) { - Index newTableId = 0; Index rangeTableIndex = 1; ListCell *rangeTableCell = NULL; @@ -1530,14 +1529,15 @@ NewTableId(Index originalTableId, List *rangeTableList) listMember = list_member_int(originalTableIdList, originalTableId); if (listMember) { - newTableId = rangeTableIndex; - break; + return rangeTableIndex; } rangeTableIndex++; } - return newTableId; + ereport(ERROR, (errmsg("Unrecognized range table id %d", (int) originalTableId))); + + return 0; } diff --git a/src/test/regress/expected/multi_view.out b/src/test/regress/expected/multi_view.out index b8e02b49f..f8444c562 100644 --- a/src/test/regress/expected/multi_view.out +++ b/src/test/regress/expected/multi_view.out @@ -236,13 +236,13 @@ CREATE VIEW lineitems_by_shipping_method AS SELECT l_shipmode, count(*) as cnt FROM lineitem_hash_part GROUP BY 1; -- following will fail due to non-flattening of subquery due to GROUP BY SELECT * FROM lineitems_by_shipping_method; -ERROR: bogus varno: 0 +ERROR: Unrecognized range table id 1 -- create a view with group by on partition column CREATE VIEW lineitems_by_orderkey AS SELECT l_orderkey, count(*) FROM lineitem_hash_part GROUP BY 1; -- this will also fail due to same reason SELECT * FROM lineitems_by_orderkey; -ERROR: bogus varno: 0 +ERROR: Unrecognized range table id 1 -- however it would work if it is made router plannable SELECT * FROM lineitems_by_orderkey WHERE l_orderkey = 100; l_orderkey | count