Re: bgwriter, inherited temp tables TODO items?
От | Tom Lane |
---|---|
Тема | Re: bgwriter, inherited temp tables TODO items? |
Дата | |
Msg-id | 23416.1123014894@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: bgwriter, inherited temp tables TODO items? ("Thomas F. O'Connell" <tfo@sitening.com>) |
Список | pgsql-hackers |
"Thomas F. O'Connell" <tfo@sitening.com> writes: > Tom seems to come pretty close to a TODO item in his analysis in my > opinion. Something like: > "Make the planner ignore temp tables of other backends when expanding > an inheritance list." I've done this in CVS tip. I'm not sure whether it should be considered a backpatchable bug fix, though. If you want to apply the patch locally, it's attached --- should work fine in 8.0, but I'm not sure about 7.4 or earlier, which have slightly different logic here. regards, tom lane *** src/backend/optimizer/prep/prepunion.c.orig Thu Jul 28 18:27:00 2005 --- src/backend/optimizer/prep/prepunion.c Tue Aug 2 16:21:41 2005 *************** *** 22,27 **** --- 22,28 ---- #include "access/heapam.h" + #include "catalog/namespace.h" #include "catalog/pg_type.h" #include "nodes/makefuncs.h" #include "optimizer/clauses.h" *************** *** 808,813 **** --- 809,824 ---- Index childRTindex; /* + * It is possible that the parent table has children that are + * temp tables of other backends. We cannot safely access such + * tables (because of buffering issues), and the best thing to do + * seems to be to silently ignore them. + */ + if (childOID != parentOID && + isOtherTempNamespace(get_rel_namespace(childOID))) + continue; + + /* * Build an RTE for the child, and attach to query's rangetable * list. We copy most fieldsof the parent's RTE, but replace * relation OID, and set inh = false. *************** *** 818,823 **** --- 829,845 ---- parse->rtable = lappend(parse->rtable, childrte); childRTindex = list_length(parse->rtable); inhRTIs = lappend_int(inhRTIs, childRTindex); + } + + /* + * If all the children were temp tables, pretend it's a non-inheritance + * situation. The duplicate RTE we added for the parent table is harmless. + */ + if (list_length(inhRTIs) < 2) + { + /* Clear flag to save repeated tests if called again */ + rte->inh = false; + return NIL; } /*
В списке pgsql-hackers по дате отправления: