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

Commit6543d81

Browse files
committed
Restructure handling of inheritance queries so that they work with outer
joins, and clean things up a good deal at the same time. Append plan nodeno longer hacks on rangetable at runtime --- instead, all child tables aregiven their own RT entries during planning. Concept of multiple targettables pushed up into execMain, replacing bug-prone implementation withinnodeAppend. Planner now supports generating Append plans for inheritancesets either at the top of the plan (the old way) or at the bottom. Expandingat the bottom is appropriate for tables used as sources, since they mayappear inside an outer join; but we must still expand at the top when thetarget of an UPDATE or DELETE is an inheritance set, because we actually needa different targetlist and junkfilter for each target table in that case.Fortunately a target table can't be inside an outer join... Bizarre mutualrecursion between union_planner and prepunion.c is gone --- in fact,union_planner doesn't really have much to do with union queries anymore,so I renamed it grouping_planner.
1 parent609f919 commit6543d81

37 files changed

+1247
-1242
lines changed

‎src/backend/commands/command.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.109 2000/11/08 22:09:57 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.110 2000/11/12 00:36:56 tgl Exp $
1212
*
1313
* NOTES
1414
* The PerformAddAttribute() code, like most of the relation
@@ -1098,23 +1098,22 @@ AlterTableAddConstraint(char *relationName,
10981098
caseCONSTR_CHECK:
10991099
{
11001100
ParseState*pstate;
1101-
boolsuccessful=TRUE;
1101+
boolsuccessful=true;
11021102
HeapScanDescscan;
11031103
ExprContext*econtext;
11041104
TupleTableSlot*slot=makeNode(TupleTableSlot);
11051105
HeapTupletuple;
11061106
RangeTblEntry*rte;
1107-
List*rtlist;
11081107
List*qual;
11091108
List*constlist;
11101109
Relationrel;
11111110
Node*expr;
11121111
char*name;
11131112

11141113
if (constr->name)
1115-
name=constr->name;
1114+
name=constr->name;
11161115
else
1117-
name="<unnamed>";
1116+
name="<unnamed>";
11181117

11191118
constlist=makeList1(constr);
11201119

@@ -1169,13 +1168,6 @@ AlterTableAddConstraint(char *relationName,
11691168

11701169
qual=makeList1(expr);
11711170

1172-
rte=makeNode(RangeTblEntry);
1173-
rte->relname=relationName;
1174-
rte->relid=RelationGetRelid(rel);
1175-
rte->eref=makeNode(Attr);
1176-
rte->eref->relname=relationName;
1177-
rtlist=makeList1(rte);
1178-
11791171
/*
11801172
* Scan through the rows now, making the necessary things
11811173
* for ExecQual, and then call it to evaluate the
@@ -1188,10 +1180,8 @@ AlterTableAddConstraint(char *relationName,
11881180
slot->ttc_descIsNew= true;
11891181
slot->ttc_tupleDescriptor=rel->rd_att;
11901182
slot->ttc_buffer=InvalidBuffer;
1191-
slot->ttc_whichplan=-1;
11921183

11931184
econtext=MakeExprContext(slot,CurrentMemoryContext);
1194-
econtext->ecxt_range_table=rtlist;/* range table */
11951185
if (!ExecQual(qual,econtext, true))
11961186
{
11971187
successful=false;
@@ -1201,8 +1191,6 @@ AlterTableAddConstraint(char *relationName,
12011191
}
12021192

12031193
pfree(slot);
1204-
pfree(rtlist);
1205-
pfree(rte);
12061194

12071195
heap_endscan(scan);
12081196
heap_close(rel,NoLock);

‎src/backend/commands/copy.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.122 2000/09/06 14:15:16 petere Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.123 2000/11/12 00:36:56 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -597,7 +597,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp,
597597
int32ntuples,
598598
tuples_read=0;
599599
boolreading_to_eof= true;
600-
RelationInfo*relationInfo;
600+
ResultRelInfo*resultRelInfo;
601601
EState*estate=CreateExecutorState();/* for ExecConstraints() */
602602
TupleTabletupleTable;
603603
TupleTableSlot*slot;
@@ -609,20 +609,19 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp,
609609
attr_count=tupDesc->natts;
610610

611611
/*
612-
* We need aRelationInfo so we can use the regular executor's
612+
* We need aResultRelInfo so we can use the regular executor's
613613
* index-entry-making machinery. (There used to be a huge amount
614614
* of code here that basically duplicated execUtils.c ...)
615615
*/
616-
relationInfo=makeNode(RelationInfo);
617-
relationInfo->ri_RangeTableIndex=1;/* dummy */
618-
relationInfo->ri_RelationDesc=rel;
619-
relationInfo->ri_NumIndices=0;
620-
relationInfo->ri_IndexRelationDescs=NULL;
621-
relationInfo->ri_IndexRelationInfo=NULL;
616+
resultRelInfo=makeNode(ResultRelInfo);
617+
resultRelInfo->ri_RangeTableIndex=1;/* dummy */
618+
resultRelInfo->ri_RelationDesc=rel;
622619

623-
ExecOpenIndices(relationInfo);
620+
ExecOpenIndices(resultRelInfo);
624621

625-
estate->es_result_relation_info=relationInfo;
622+
estate->es_result_relations=resultRelInfo;
623+
estate->es_num_result_relations=1;
624+
estate->es_result_relation_info=resultRelInfo;
626625

627626
/* Set up a dummy tuple table too */
628627
tupleTable=ExecCreateTupleTable(1);
@@ -830,15 +829,15 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp,
830829
ExecStoreTuple(tuple,slot,InvalidBuffer, false);
831830

832831
if (rel->rd_att->constr)
833-
ExecConstraints("CopyFrom",rel,slot,estate);
832+
ExecConstraints("CopyFrom",resultRelInfo,slot,estate);
834833

835834
/* ----------------
836835
* OK, store the tuple and create index entries for it
837836
* ----------------
838837
*/
839838
heap_insert(rel,tuple);
840839

841-
if (relationInfo->ri_NumIndices>0)
840+
if (resultRelInfo->ri_NumIndices>0)
842841
ExecInsertIndexTuples(slot,&(tuple->t_self),estate, false);
843842

844843
/* AFTER ROW INSERT Triggers */
@@ -886,7 +885,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp,
886885

887886
ExecDropTupleTable(tupleTable, true);
888887

889-
ExecCloseIndices(relationInfo);
888+
ExecCloseIndices(resultRelInfo);
890889
}
891890

892891

‎src/backend/commands/explain.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
66
* Portions Copyright (c) 1994-5, Regents of the University of California
77
*
8-
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.61 2000/10/26 21:34:44 tgl Exp $
8+
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.62 2000/11/12 00:36:56 tgl Exp $
99
*
1010
*/
1111

@@ -327,32 +327,18 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
327327
if (IsA(plan,Append))
328328
{
329329
Append*appendplan= (Append*)plan;
330-
List*saved_rtable=es->rtable;
331-
intwhichplan=0;
332330
List*lst;
333331

334332
foreach(lst,appendplan->appendplans)
335333
{
336334
Plan*subnode= (Plan*)lfirst(lst);
337335

338-
if (appendplan->inheritrelid>0)
339-
{
340-
RangeTblEntry*rtentry;
341-
342-
rtentry=nth(whichplan,appendplan->inheritrtable);
343-
Assert(rtentry!=NULL);
344-
rt_store(appendplan->inheritrelid,es->rtable,rtentry);
345-
}
346-
347336
for (i=0;i<indent;i++)
348337
appendStringInfo(str," ");
349338
appendStringInfo(str," -> ");
350339

351340
explain_outNode(str,subnode,indent+3,es);
352-
353-
whichplan++;
354341
}
355-
es->rtable=saved_rtable;
356342
}
357343

358344
if (IsA(plan,SubqueryScan))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp