On 2012/11/07, at 1:35, Tom Lane <t...@sss.pgh.pa.us> wrote: > >> Isn't it possible to pick-up only columns to be used in targetlist or >> local qualifiers, without modification of baserestrictinfo? > > What the doc means to suggest is that you can look through the > baserestrictinfo list and then record information elsewhere about > interesting clauses you find. If the FDW is actually *modifying* that > list, I agree that seems like a bad idea. Kaigai-san might have misunderstood that postgresql_fdw changes baserestrictinfo, since it did so in old implementation.
ClassifyConditions creates new lists, local_conds and remote_conds, which have cells which point RestrictInfo(s) in baserestrictinfo. It doesn't copy RestrictInfo for new lists, but I think it's ok because baserestrictinfo list itself and RestrictInfo(s) pointed by it are never modified by postgresql_fdw. > I don't recall anything in > the core system that does that, so it seems fragile. The closest > parallel I can think of in the core system is indexscans pulling out > restriction clauses to use as index quals. That code doesn't modify > the baserestrictinfo list, only make new lists with some of the same > entries. Thanks for the advise. I found relation_excluded_by_constraints which is called by set_rel_size() creates new RestrictInfo list from baserestrictinfo, and this seems like what postgresql_fdw does in GetForeignRelSize, from the perspective of relation size estimation. Regards, -- Shigeru HANADA shigeru.han...@gmail.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers