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

Commit5b9d655

Browse files
committed
Avoid duplicate ExecTypeFromTL() call in ExecInitJunkFilter() by passing
in the TupleDesc that the caller already has (for call from ExecMain) orcan make just as easily as ExecInitJunkFilter() can (for call fromExecAppend). Also, don't bother to build a junk filter for an INSERToperation that doesn't actually need one, which is the normal case.
1 parent4ce4d7f commit5b9d655

File tree

4 files changed

+40
-49
lines changed

4 files changed

+40
-49
lines changed

‎src/backend/executor/execJunk.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.20 1999/07/17 20:16:56 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.21 1999/10/30 23:13:30 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -55,17 +55,18 @@
5555
* ExecInitJunkFilter
5656
*
5757
* Initialize the Junk filter.
58+
*
59+
* The initial targetlist and associated tuple descriptor are passed in.
5860
*-------------------------------------------------------------------------
5961
*/
6062
JunkFilter*
61-
ExecInitJunkFilter(List*targetList)
63+
ExecInitJunkFilter(List*targetList,TupleDesctupType)
6264
{
6365
JunkFilter*junkfilter;
6466
List*cleanTargetList;
6567
intlen,
6668
cleanLength;
67-
TupleDesctupType,
68-
cleanTupType;
69+
TupleDesccleanTupType;
6970
List*t;
7071
TargetEntry*tle;
7172
Resdom*resdom,
@@ -154,15 +155,11 @@ ExecInitJunkFilter(List *targetList)
154155
}
155156

156157
/* ---------------------
157-
* Now calculate the tuple types for the original and the clean tuple
158-
*
159-
* XXX ExecTypeFromTL should be used sparingly. Don't we already
160-
* have the tupType corresponding to the targetlist we are passed?
161-
* -cim 5/31/91
158+
* Now calculate the tuple type for the cleaned tuple (we were already
159+
* given the type for the original targetlist).
162160
* ---------------------
163161
*/
164-
tupType= (TupleDesc)ExecTypeFromTL(targetList);
165-
cleanTupType= (TupleDesc)ExecTypeFromTL(cleanTargetList);
162+
cleanTupType=ExecTypeFromTL(cleanTargetList);
166163

167164
len=ExecTargetListLength(targetList);
168165
cleanLength=ExecTargetListLength(cleanTargetList);

‎src/backend/executor/execMain.c

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*
2828
* IDENTIFICATION
29-
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.97 1999/10/07 04:23:01 tgl Exp $
29+
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.98 1999/10/3023:13:30 tgl Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -529,7 +529,6 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
529529
RelationintoRelationDesc;
530530
TupleDesctupType;
531531
List*targetList;
532-
intlen;
533532

534533
/*
535534
* get information from query descriptor
@@ -655,40 +654,43 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
655654
*/
656655
tupType=ExecGetTupType(plan);/* tuple descriptor */
657656
targetList=plan->targetlist;
658-
len=ExecTargetListLength(targetList);/* number of attributes */
659657

660658
/*
661-
* now that we have the target list, initialize the junk filter if
662-
* this is a REPLACE or a DELETE query. We also init the junk filter
663-
* if this is an append query (there might be some rule lock info
664-
* there...) NOTE: in the future we might want to initialize the junk
665-
* filter for all queries. SELECT added by daveh@insightdist.com
666-
* 5/20/98 to allow ORDER/GROUP BY have an identifier missing from the
667-
* target.
659+
* Now that we have the target list, initialize the junk filter if needed.
660+
* SELECT and INSERT queries need a filter if there are any junk attrs
661+
* in the tlist. UPDATE and DELETE always need one, since there's always
662+
* a junk 'ctid' attribute present --- no need to look first.
668663
*/
669664
{
670665
booljunk_filter_needed= false;
671666
List*tlist;
672667

673-
if (operation==CMD_SELECT)
668+
switch (operation)
674669
{
675-
foreach(tlist,targetList)
676-
{
677-
TargetEntry*tle=lfirst(tlist);
678-
679-
if (tle->resdom->resjunk)
670+
caseCMD_SELECT:
671+
caseCMD_INSERT:
672+
foreach(tlist,targetList)
680673
{
681-
junk_filter_needed= true;
682-
break;
674+
TargetEntry*tle= (TargetEntry*)lfirst(tlist);
675+
676+
if (tle->resdom->resjunk)
677+
{
678+
junk_filter_needed= true;
679+
break;
680+
}
683681
}
684-
}
682+
break;
683+
caseCMD_UPDATE:
684+
caseCMD_DELETE:
685+
junk_filter_needed= true;
686+
break;
687+
default:
688+
break;
685689
}
686690

687-
if (operation==CMD_UPDATE||operation==CMD_DELETE||
688-
operation==CMD_INSERT||
689-
(operation==CMD_SELECT&&junk_filter_needed))
691+
if (junk_filter_needed)
690692
{
691-
JunkFilter*j=(JunkFilter*)ExecInitJunkFilter(targetList);
693+
JunkFilter*j=ExecInitJunkFilter(targetList,tupType);
692694

693695
estate->es_junkFilter=j;
694696

‎src/backend/executor/nodeAppend.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.26 1999/09/24 00:24:23 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.27 1999/10/30 23:13:30 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -276,9 +276,6 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
276276

277277
for (i=0;i<nplans;i++)
278278
{
279-
JunkFilter*j;
280-
List*targetList;
281-
282279
/* ----------------
283280
*NOTE: we first modify range table in
284281
* exec_append_initialize_next() and
@@ -302,9 +299,8 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
302299
if ((es_rri!= (RelationInfo*)NULL)&&
303300
(node->inheritrelid==es_rri->ri_RangeTableIndex))
304301
{
305-
306-
targetList=initNode->targetlist;
307-
j= (JunkFilter*)ExecInitJunkFilter(targetList);
302+
JunkFilter*j=ExecInitJunkFilter(initNode->targetlist,
303+
ExecGetTupType(initNode));
308304
junkList=lappend(junkList,j);
309305
}
310306

@@ -318,9 +314,7 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
318314
* ----------------
319315
*/
320316
initNode= (Plan*)nth(0,appendplans);
321-
ExecAssignResultType(&appendstate->cstate,
322-
/* ExecGetExecTupDesc(initNode), */
323-
ExecGetTupType(initNode));
317+
ExecAssignResultType(&appendstate->cstate,ExecGetTupType(initNode));
324318
appendstate->cstate.cs_ProjInfo=NULL;
325319

326320
/* ----------------
@@ -329,9 +323,7 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
329323
*/
330324
appendstate->as_whichplan=0;
331325
exec_append_initialize_next(node);
332-
#ifdefNOT_USED
333-
result= (List*)initialized[0];
334-
#endif
326+
335327
return TRUE;
336328
}
337329

‎src/include/executor/executor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: executor.h,v 1.38 1999/09/24 00:25:10 tgl Exp $
9+
* $Id: executor.h,v 1.39 1999/10/30 23:13:30 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -53,7 +53,7 @@ extern Relation ExecCreatR(TupleDesc tupType, Oid relationOid);
5353
/*
5454
* prototypes from functions in execJunk.c
5555
*/
56-
externJunkFilter*ExecInitJunkFilter(List*targetList);
56+
externJunkFilter*ExecInitJunkFilter(List*targetList,TupleDesctupType);
5757
externboolExecGetJunkAttribute(JunkFilter*junkfilter,TupleTableSlot*slot,
5858
char*attrName,Datum*value,bool*isNull);
5959
externHeapTupleExecRemoveJunk(JunkFilter*junkfilter,TupleTableSlot*slot);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp