@ -1360,8 +1360,12 @@ expand_inherited_tables(PlannerInfo *root)
* table , but with inh = false , to represent the parent table in its role
* table , but with inh = false , to represent the parent table in its role
* as a simple member of the inheritance set .
* as a simple member of the inheritance set .
*
*
* A childless table is never considered to be an inheritance set ; therefore
* A childless table is never considered to be an inheritance set . For
* a parent RTE must always have at least two associated AppendRelInfos .
* regular inheritance , a parent RTE must always have at least two associated
* AppendRelInfos : one corresponding to the parent table as a simple member of
* inheritance set and one or more corresponding to the actual children .
* Since a partitioned table is not scanned , it might have only one associated
* AppendRelInfo .
*/
*/
static void
static void
expand_inherited_rtentry ( PlannerInfo * root , RangeTblEntry * rte , Index rti )
expand_inherited_rtentry ( PlannerInfo * root , RangeTblEntry * rte , Index rti )
@ -1374,7 +1378,7 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti)
List * inhOIDs ;
List * inhOIDs ;
List * appinfos ;
List * appinfos ;
ListCell * l ;
ListCell * l ;
bool need_appen d;
bool has_chil d;
PartitionedChildRelInfo * pcinfo ;
PartitionedChildRelInfo * pcinfo ;
List * partitioned_child_rels = NIL ;
List * partitioned_child_rels = NIL ;
@ -1448,7 +1452,7 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti)
/* Scan the inheritance set and expand it */
/* Scan the inheritance set and expand it */
appinfos = NIL ;
appinfos = NIL ;
need_appen d = false ;
has_chil d = false ;
foreach ( l , inhOIDs )
foreach ( l , inhOIDs )
{
{
Oid childOID = lfirst_oid ( l ) ;
Oid childOID = lfirst_oid ( l ) ;
@ -1502,7 +1506,10 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti)
*/
*/
if ( childrte - > relkind ! = RELKIND_PARTITIONED_TABLE )
if ( childrte - > relkind ! = RELKIND_PARTITIONED_TABLE )
{
{
need_append = true ;
/* Remember if we saw a real child. */
if ( childOID ! = parentOID )
has_child = true ;
appinfo = makeNode ( AppendRelInfo ) ;
appinfo = makeNode ( AppendRelInfo ) ;
appinfo - > parent_relid = rti ;
appinfo - > parent_relid = rti ;
appinfo - > child_relid = childRTindex ;
appinfo - > child_relid = childRTindex ;
@ -1582,7 +1589,7 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti)
* the parent table is harmless , so we don ' t bother to get rid of it ;
* the parent table is harmless , so we don ' t bother to get rid of it ;
* ditto for the useless PlanRowMark node .
* ditto for the useless PlanRowMark node .
*/
*/
if ( ! need_appen d)
if ( ! has_chil d)
{
{
/* Clear flag before returning */
/* Clear flag before returning */
rte - > inh = false ;
rte - > inh = false ;