Report error when original range table id is not found in NewTableId()

pull/1024/head
Murat Tuncer 2016-12-28 16:10:41 +03:00
parent 77f8db6b14
commit e7935a3be4
2 changed files with 6 additions and 6 deletions

View File

@ -1515,7 +1515,6 @@ UpdateColumnAttributes(Var *column, List *rangeTableList, List *dependedJobList)
static Index static Index
NewTableId(Index originalTableId, List *rangeTableList) NewTableId(Index originalTableId, List *rangeTableList)
{ {
Index newTableId = 0;
Index rangeTableIndex = 1; Index rangeTableIndex = 1;
ListCell *rangeTableCell = NULL; ListCell *rangeTableCell = NULL;
@ -1530,14 +1529,15 @@ NewTableId(Index originalTableId, List *rangeTableList)
listMember = list_member_int(originalTableIdList, originalTableId); listMember = list_member_int(originalTableIdList, originalTableId);
if (listMember) if (listMember)
{ {
newTableId = rangeTableIndex; return rangeTableIndex;
break;
} }
rangeTableIndex++; rangeTableIndex++;
} }
return newTableId; ereport(ERROR, (errmsg("Unrecognized range table id %d", (int) originalTableId)));
return 0;
} }

View File

@ -236,13 +236,13 @@ CREATE VIEW lineitems_by_shipping_method AS
SELECT l_shipmode, count(*) as cnt FROM lineitem_hash_part GROUP BY 1; 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 -- following will fail due to non-flattening of subquery due to GROUP BY
SELECT * FROM lineitems_by_shipping_method; 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 a view with group by on partition column
CREATE VIEW lineitems_by_orderkey AS CREATE VIEW lineitems_by_orderkey AS
SELECT l_orderkey, count(*) FROM lineitem_hash_part GROUP BY 1; SELECT l_orderkey, count(*) FROM lineitem_hash_part GROUP BY 1;
-- this will also fail due to same reason -- this will also fail due to same reason
SELECT * FROM lineitems_by_orderkey; 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 -- however it would work if it is made router plannable
SELECT * FROM lineitems_by_orderkey WHERE l_orderkey = 100; SELECT * FROM lineitems_by_orderkey WHERE l_orderkey = 100;
l_orderkey | count l_orderkey | count