From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Thomas F(dot) O'Connell" <tfo(at)sitening(dot)com> |
Cc: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, PgSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: bgwriter, inherited temp tables TODO items? |
Date: | 2005-08-02 20:34:54 |
Message-ID: | 23416.1123014894@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
"Thomas F. O'Connell" <tfo(at)sitening(dot)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 fields of 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;
}
/*
From | Date | Subject | |
---|---|---|---|
Next Message | Mark Wong | 2005-08-02 21:22:43 | dbt3 data with 10GB scale factor |
Previous Message | Marc G. Fournier | 2005-08-02 19:31:42 | [8.0.3] Not dumping all sequences ... |