@@ -93,15 +93,14 @@ typedef struct
9393CommonTableExpr * parent_cte ;
9494}transform_query_cxt ;
9595
96-
9796typedef struct
9897{
9998Index child_varno ;
99+ Oid parent_relid ;
100100List * translated_vars ;
101101}adjust_appendrel_varnos_cxt ;
102102
103103
104-
105104static bool pathman_transform_query_walker (Node * node ,void * context );
106105
107106static void disable_standard_inheritance (Query * parse ,transform_query_cxt * context );
@@ -473,9 +472,9 @@ handle_modification_query(Query *parse, transform_query_cxt *context)
473472
474473/* Translate varnos for this child */
475474aav_cxt .child_varno = result_rti ;
475+ aav_cxt .parent_relid = parent ;
476476aav_cxt .translated_vars = translated_vars ;
477- if (adjust_appendrel_varnos ((Node * )parse ,& aav_cxt ))
478- return ;/* failed to perform rewrites */
477+ adjust_appendrel_varnos ((Node * )parse ,& aav_cxt );
479478
480479/* Translate column privileges for this child */
481480rte -> selectedCols = translate_col_privs (rte -> selectedCols ,translated_vars );
@@ -561,6 +560,7 @@ eval_extern_params_mutator(Node *node, ParamListInfo params)
561560 (void * )params );
562561}
563562
563+ /* Remap parent's attributes to child ones s*/
564564static bool
565565adjust_appendrel_varnos (Node * node ,adjust_appendrel_varnos_cxt * context )
566566{
@@ -572,6 +572,7 @@ adjust_appendrel_varnos(Node *node, adjust_appendrel_varnos_cxt *context)
572572Query * query = (Query * )node ;
573573ListCell * lc ;
574574
575+ /* FIXME: we might need to reorder TargetEntries */
575576foreach (lc ,query -> targetList )
576577{
577578TargetEntry * te = (TargetEntry * )lfirst (lc );
@@ -581,11 +582,13 @@ adjust_appendrel_varnos(Node *node, adjust_appendrel_varnos_cxt *context)
581582continue ;
582583
583584if (te -> resno > list_length (context -> translated_vars ))
584- return true;
585+ elog (ERROR ,"attribute %d of relation \"%s\" does not exist" ,
586+ te -> resno ,get_rel_name (context -> parent_relid ));
585587
586588child_var = list_nth (context -> translated_vars ,te -> resno - 1 );
587589if (!child_var )
588- return true;
590+ elog (ERROR ,"attribute %d of relation \"%s\" does not exist" ,
591+ te -> resno ,get_rel_name (context -> parent_relid ));
589592
590593/* Transform attribute number */
591594te -> resno = child_var -> varattno ;
@@ -601,17 +604,19 @@ adjust_appendrel_varnos(Node *node, adjust_appendrel_varnos_cxt *context)
601604{
602605Var * var = (Var * )node ;
603606
604- /* Don'ttranform system columns & other relations' Vars */
607+ /* Don'ttransform system columns & other relations' Vars */
605608if (var -> varoattno > 0 && var -> varno == context -> child_varno )
606609{
607610Var * child_var ;
608611
609612if (var -> varattno > list_length (context -> translated_vars ))
610- return true;
613+ elog (ERROR ,"attribute %d of relation \"%s\" does not exist" ,
614+ var -> varattno ,get_rel_name (context -> parent_relid ));
611615
612616child_var = list_nth (context -> translated_vars ,var -> varattno - 1 );
613617if (!child_var )
614- return true;
618+ elog (ERROR ,"attribute %d of relation \"%s\" does not exist" ,
619+ var -> varattno ,get_rel_name (context -> parent_relid ));
615620
616621/* Transform attribute number */
617622var -> varattno = child_var -> varattno ;