Re: Passing fdw_private data from PlanForeignScan to PlanForeignModify

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Passing fdw_private data from PlanForeignScan to PlanForeignModify
Дата
Msg-id 19844.1371161525@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Passing fdw_private data from PlanForeignScan to PlanForeignModify  (Bernd Helmle <mailings@oopsware.de>)
Ответы Re: Passing fdw_private data from PlanForeignScan to PlanForeignModify  (Bernd Helmle <mailings@oopsware.de>)
Список pgsql-hackers
Bernd Helmle <mailings@oopsware.de> writes:
> What i tried before was to access (in PlanForeignModify) the RelOptInfo 
> structure through PlannerInfo->simple_rel_array, assuming the the 
> resultRelation index points to the right array member. However, that didn't 
> work, the fdw_private List is not the one filled by GetForeignPlan...is 
> there another way to get back the RelOptInfo worked on earlier?

It should work ... *if* there was in fact a RelOptInfo worked on
earlier.  There sometimes isn't.  You might need to do something like
what make_modifytable() has to do to call you in the first place:
       /*        * If possible, we want to get the FdwRoutine from our RelOptInfo for        * the table.  But
sometimeswe don't have a RelOptInfo and must get        * it the hard way.  (In INSERT, the target relation is not
scanned,       * so it's not a baserel; and there are also corner cases for        * updatable views where the target
relisn't a baserel.)        */       if (rti < root->simple_rel_array_size &&           root->simple_rel_array[rti] !=
NULL)      {           RelOptInfo *resultRel = root->simple_rel_array[rti];
 
           fdwroutine = resultRel->fdwroutine;       }       else       {           RangeTblEntry *rte =
planner_rt_fetch(rti,root);
 
           Assert(rte->rtekind == RTE_RELATION);           if (rte->relkind == RELKIND_FOREIGN_TABLE)
fdwroutine= GetFdwRoutineByRelId(rte->relid);           else               fdwroutine = NULL;       }
 
       if (fdwroutine != NULL &&           fdwroutine->PlanForeignModify != NULL)           fdw_private =
fdwroutine->PlanForeignModify(root,node, rti, i);
 


[ jargon alert: "baserel" here basically means "a table the query has
to scan". ]
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Jeff Janes
Дата:
Сообщение: single-user vs standalone in docs and messages
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: single-user vs standalone in docs and messages