Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit688784f

Browse files
committed
Prevent planner from including temp tables of other backends when expanding
an inheritance tree. Per recent discussions.
1 parent558730a commit688784f

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

‎src/backend/optimizer/prep/prepunion.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
*
1515
*
1616
* IDENTIFICATION
17-
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.125 2005/07/28 22:27:00 tgl Exp $
17+
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.126 2005/08/02 20:27:45 tgl Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
2121
#include"postgres.h"
2222

2323

2424
#include"access/heapam.h"
25+
#include"catalog/namespace.h"
2526
#include"catalog/pg_type.h"
2627
#include"nodes/makefuncs.h"
2728
#include"optimizer/clauses.h"
@@ -807,6 +808,16 @@ expand_inherited_rtentry(PlannerInfo *root, Index rti)
807808
RangeTblEntry*childrte;
808809
IndexchildRTindex;
809810

811+
/*
812+
* It is possible that the parent table has children that are
813+
* temp tables of other backends. We cannot safely access such
814+
* tables (because of buffering issues), and the best thing to do
815+
* seems to be to silently ignore them.
816+
*/
817+
if (childOID!=parentOID&&
818+
isOtherTempNamespace(get_rel_namespace(childOID)))
819+
continue;
820+
810821
/*
811822
* Build an RTE for the child, and attach to query's rangetable
812823
* list. We copy most fields of the parent's RTE, but replace
@@ -820,6 +831,17 @@ expand_inherited_rtentry(PlannerInfo *root, Index rti)
820831
inhRTIs=lappend_int(inhRTIs,childRTindex);
821832
}
822833

834+
/*
835+
* If all the children were temp tables, pretend it's a non-inheritance
836+
* situation. The duplicate RTE we added for the parent table is harmless.
837+
*/
838+
if (list_length(inhRTIs)<2)
839+
{
840+
/* Clear flag to save repeated tests if called again */
841+
rte->inh= false;
842+
returnNIL;
843+
}
844+
823845
/*
824846
* The executor will check the parent table's access permissions when
825847
* it examines the parent's inheritlist entry. There's no need to

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp