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

Commitad161bc

Browse files
committed
Merge Resdom nodes into TargetEntry nodes to simplify code and save a
few palloc's. I also chose to eliminate the restype and restypmod fieldsentirely, since they are redundant with information stored in the node'scontained expression; re-examining the expression at need seems simplerand more reliable than trying to keep restype/restypmod up to date.initdb forced due to change in contents of stored rules.
1 parent0f3748a commitad161bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+539
-801
lines changed

‎src/backend/access/common/printtup.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/access/common/printtup.c,v 1.87 2005/03/16 21:38:04 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/access/common/printtup.c,v 1.88 2005/04/06 16:34:04 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -190,14 +190,14 @@ SendRowDescriptionMessage(TupleDesc typeinfo, List *targetlist, int16 *formats)
190190
{
191191
/* Do we have a non-resjunk tlist item? */
192192
while (tlist_item&&
193-
((TargetEntry*)lfirst(tlist_item))->resdom->resjunk)
193+
((TargetEntry*)lfirst(tlist_item))->resjunk)
194194
tlist_item=lnext(tlist_item);
195195
if (tlist_item)
196196
{
197-
Resdom*res= ((TargetEntry*)lfirst(tlist_item))->resdom;
197+
TargetEntry*tle= (TargetEntry*)lfirst(tlist_item);
198198

199-
pq_sendint(&buf,res->resorigtbl,4);
200-
pq_sendint(&buf,res->resorigcol,2);
199+
pq_sendint(&buf,tle->resorigtbl,4);
200+
pq_sendint(&buf,tle->resorigcol,2);
201201
tlist_item=lnext(tlist_item);
202202
}
203203
else

‎src/backend/commands/view.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/view.c,v 1.87 2005/02/02 06:36:00 neilc Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/view.c,v 1.88 2005/04/06 16:34:04 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -22,6 +22,7 @@
2222
#include"miscadmin.h"
2323
#include"nodes/makefuncs.h"
2424
#include"optimizer/clauses.h"
25+
#include"parser/parse_expr.h"
2526
#include"parser/parse_relation.h"
2627
#include"rewrite/rewriteDefine.h"
2728
#include"rewrite/rewriteManip.h"
@@ -106,18 +107,17 @@ DefineVirtualRelation(const RangeVar *relation, List *tlist, bool replace)
106107
attrList=NIL;
107108
foreach(t,tlist)
108109
{
109-
TargetEntry*entry=lfirst(t);
110-
Resdom*res=entry->resdom;
110+
TargetEntry*tle=lfirst(t);
111111

112-
if (!res->resjunk)
112+
if (!tle->resjunk)
113113
{
114114
ColumnDef*def=makeNode(ColumnDef);
115115
TypeName*typename=makeNode(TypeName);
116116

117-
def->colname=pstrdup(res->resname);
117+
def->colname=pstrdup(tle->resname);
118118

119-
typename->typeid=res->restype;
120-
typename->typmod=res->restypmod;
119+
typename->typeid=exprType((Node*)tle->expr);
120+
typename->typmod=exprTypmod((Node*)tle->expr);
121121
def->typename=typename;
122122

123123
def->inhcount=0;

‎src/backend/executor/execJunk.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/execJunk.c,v 1.48 2005/03/16 21:38:06 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/execJunk.c,v 1.49 2005/04/06 16:34:04 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -31,8 +31,8 @@
3131
* of some system attributes like "ctid" or rule locks.
3232
*
3333
* The general idea is the following: A target list consists of a list of
34-
*Resdom nodes& expression pairs. EachResdom nodehasan attribute
35-
* called 'resjunk'. If the value of thisattribute is true then the
34+
*TargetEntry nodescontaining expressions. EachTargetEntryhasa field
35+
* called 'resjunk'. If the value of thisfield is true then the
3636
* corresponding attribute is a "junk" attribute.
3737
*
3838
* When we initialize a plan we call 'ExecInitJunkFilter' to create
@@ -101,11 +101,10 @@ ExecInitJunkFilter(List *targetList, bool hasoid, TupleTableSlot *slot)
101101
foreach(t,targetList)
102102
{
103103
TargetEntry*tle=lfirst(t);
104-
Resdom*resdom=tle->resdom;
105104

106-
if (!resdom->resjunk)
105+
if (!tle->resjunk)
107106
{
108-
cleanMap[cleanResno-1]=resdom->resno;
107+
cleanMap[cleanResno-1]=tle->resno;
109108
cleanResno++;
110109
}
111110
}
@@ -177,12 +176,11 @@ ExecInitJunkFilterConversion(List *targetList,
177176
for (;;)
178177
{
179178
TargetEntry*tle=lfirst(t);
180-
Resdom*resdom=tle->resdom;
181179

182180
t=lnext(t);
183-
if (!resdom->resjunk)
181+
if (!tle->resjunk)
184182
{
185-
cleanMap[i]=resdom->resno;
183+
cleanMap[i]=tle->resno;
186184
break;
187185
}
188186
}
@@ -228,13 +226,12 @@ ExecGetJunkAttribute(JunkFilter *junkfilter,
228226
foreach(t,junkfilter->jf_targetList)
229227
{
230228
TargetEntry*tle=lfirst(t);
231-
Resdom*resdom=tle->resdom;
232229

233-
if (resdom->resjunk&&resdom->resname&&
234-
(strcmp(resdom->resname,attrName)==0))
230+
if (tle->resjunk&&tle->resname&&
231+
(strcmp(tle->resname,attrName)==0))
235232
{
236233
/* We found it ! */
237-
*value=slot_getattr(slot,resdom->resno,isNull);
234+
*value=slot_getattr(slot,tle->resno,isNull);
238235
return true;
239236
}
240237
}

‎src/backend/executor/execMain.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*
2828
* IDENTIFICATION
29-
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.244 2005/03/25 21:57:58 tgl Exp $
29+
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.245 2005/04/06 16:34:04 tgl Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -640,7 +640,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
640640
{
641641
TargetEntry*tle= (TargetEntry*)lfirst(tlist);
642642

643-
if (tle->resdom->resjunk)
643+
if (tle->resjunk)
644644
{
645645
junk_filter_needed= true;
646646
break;

‎src/backend/executor/execQual.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.175 2005/03/29 00:16:59 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.176 2005/04/0616:34:04 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -3467,7 +3467,7 @@ ExecCleanTargetListLength(List *targetlist)
34673467
TargetEntry*curTle= (TargetEntry*)lfirst(tl);
34683468

34693469
Assert(IsA(curTle,TargetEntry));
3470-
if (!curTle->resdom->resjunk)
3470+
if (!curTle->resjunk)
34713471
len++;
34723472
}
34733473
returnlen;
@@ -3516,7 +3516,7 @@ ExecTargetList(List *targetlist,
35163516
{
35173517
GenericExprState*gstate= (GenericExprState*)lfirst(tl);
35183518
TargetEntry*tle= (TargetEntry*)gstate->xprstate.expr;
3519-
AttrNumberresind=tle->resdom->resno-1;
3519+
AttrNumberresind=tle->resno-1;
35203520

35213521
values[resind]=ExecEvalExpr(gstate->arg,
35223522
econtext,
@@ -3568,7 +3568,7 @@ ExecTargetList(List *targetlist,
35683568
{
35693569
GenericExprState*gstate= (GenericExprState*)lfirst(tl);
35703570
TargetEntry*tle= (TargetEntry*)gstate->xprstate.expr;
3571-
AttrNumberresind=tle->resdom->resno-1;
3571+
AttrNumberresind=tle->resno-1;
35723572

35733573
if (itemIsDone[resind]==ExprEndResult)
35743574
{
@@ -3602,7 +3602,7 @@ ExecTargetList(List *targetlist,
36023602
{
36033603
GenericExprState*gstate= (GenericExprState*)lfirst(tl);
36043604
TargetEntry*tle= (TargetEntry*)gstate->xprstate.expr;
3605-
AttrNumberresind=tle->resdom->resno-1;
3605+
AttrNumberresind=tle->resno-1;
36063606

36073607
while (itemIsDone[resind]==ExprMultipleResult)
36083608
{

‎src/backend/executor/execTuples.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.86 2005/03/17 15:25:51 tgl Exp $
18+
* $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.87 2005/04/06 16:34:04 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -784,15 +784,14 @@ ExecTypeFromTLInternal(List *targetList, bool hasoid, bool skipjunk)
784784
foreach(l,targetList)
785785
{
786786
TargetEntry*tle=lfirst(l);
787-
Resdom*resdom=tle->resdom;
788787

789-
if (skipjunk&&resdom->resjunk)
788+
if (skipjunk&&tle->resjunk)
790789
continue;
791790
TupleDescInitEntry(typeInfo,
792791
cur_resno++,
793-
resdom->resname,
794-
resdom->restype,
795-
resdom->restypmod,
792+
tle->resname,
793+
exprType((Node*)tle->expr),
794+
exprTypmod((Node*)tle->expr),
796795
0);
797796
}
798797

‎src/backend/executor/execUtils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.119 2005/03/21 01:24:03 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.120 2005/04/06 16:34:04 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -561,7 +561,7 @@ ExecBuildProjectionInfo(List *targetList,
561561
Var*variable= (Var*)gstate->arg->expr;
562562
AttrNumberattnum=variable->varattno;
563563
TargetEntry*tle= (TargetEntry*)gstate->xprstate.expr;
564-
AttrNumberresind=tle->resdom->resno-1;
564+
AttrNumberresind=tle->resno-1;
565565

566566
Assert(resind >=0&&resind<len);
567567
varNumbers[resind]=attnum;

‎src/backend/executor/functions.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.95 2005/03/31 22:46:08 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.96 2005/04/06 16:34:04 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -935,7 +935,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
935935
format_type_be(rettype)),
936936
errdetail("Final SELECT must return exactly one column.")));
937937

938-
restype=((TargetEntry*)linitial(tlist))->resdom->restype;
938+
restype=exprType((Node*) ((TargetEntry*)linitial(tlist))->expr);
939939
if (!IsBinaryCoercible(restype,rettype))
940940
ereport(ERROR,
941941
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
@@ -961,7 +961,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
961961
*/
962962
if (tlistlen==1)
963963
{
964-
restype=((TargetEntry*)linitial(tlist))->resdom->restype;
964+
restype=exprType((Node*) ((TargetEntry*)linitial(tlist))->expr);
965965
if (IsBinaryCoercible(restype,rettype))
966966
return false;/* NOT returning whole tuple */
967967
}
@@ -996,7 +996,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
996996
Oidtletype;
997997
Oidatttype;
998998

999-
if (tle->resdom->resjunk)
999+
if (tle->resjunk)
10001000
continue;
10011001

10021002
do

‎src/backend/executor/nodeSubplan.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.67 2005/03/16 21:38:08 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.68 2005/04/06 16:34:04 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -828,12 +828,10 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
828828
/* Process lefthand argument */
829829
exstate= (ExprState*)linitial(fstate->args);
830830
expr=exstate->expr;
831-
tle=makeTargetEntry(makeResdom(i,
832-
exprType((Node*)expr),
833-
exprTypmod((Node*)expr),
834-
NULL,
835-
false),
836-
expr);
831+
tle=makeTargetEntry(expr,
832+
i,
833+
NULL,
834+
false);
837835
tlestate=makeNode(GenericExprState);
838836
tlestate->xprstate.expr= (Expr*)tle;
839837
tlestate->xprstate.evalfunc=NULL;
@@ -844,12 +842,10 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
844842
/* Process righthand argument */
845843
exstate= (ExprState*)lsecond(fstate->args);
846844
expr=exstate->expr;
847-
tle=makeTargetEntry(makeResdom(i,
848-
exprType((Node*)expr),
849-
exprTypmod((Node*)expr),
850-
NULL,
851-
false),
852-
expr);
845+
tle=makeTargetEntry(expr,
846+
i,
847+
NULL,
848+
false);
853849
tlestate=makeNode(GenericExprState);
854850
tlestate->xprstate.expr= (Expr*)tle;
855851
tlestate->xprstate.evalfunc=NULL;

‎src/backend/nodes/copyfuncs.c

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.299 2005/03/29 17:58:50 tgl Exp $
18+
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.300 2005/04/06 16:34:05 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -539,26 +539,6 @@ _copyLimit(Limit *from)
539539
* ****************************************************************
540540
*/
541541

542-
/*
543-
* _copyResdom
544-
*/
545-
staticResdom*
546-
_copyResdom(Resdom*from)
547-
{
548-
Resdom*newnode=makeNode(Resdom);
549-
550-
COPY_SCALAR_FIELD(resno);
551-
COPY_SCALAR_FIELD(restype);
552-
COPY_SCALAR_FIELD(restypmod);
553-
COPY_STRING_FIELD(resname);
554-
COPY_SCALAR_FIELD(ressortgroupref);
555-
COPY_SCALAR_FIELD(resorigtbl);
556-
COPY_SCALAR_FIELD(resorigcol);
557-
COPY_SCALAR_FIELD(resjunk);
558-
559-
returnnewnode;
560-
}
561-
562542
/*
563543
* _copyAlias
564544
*/
@@ -1077,8 +1057,13 @@ _copyTargetEntry(TargetEntry *from)
10771057
{
10781058
TargetEntry*newnode=makeNode(TargetEntry);
10791059

1080-
COPY_NODE_FIELD(resdom);
10811060
COPY_NODE_FIELD(expr);
1061+
COPY_SCALAR_FIELD(resno);
1062+
COPY_STRING_FIELD(resname);
1063+
COPY_SCALAR_FIELD(ressortgroupref);
1064+
COPY_SCALAR_FIELD(resorigtbl);
1065+
COPY_SCALAR_FIELD(resorigcol);
1066+
COPY_SCALAR_FIELD(resjunk);
10821067

10831068
returnnewnode;
10841069
}
@@ -2670,9 +2655,6 @@ copyObject(void *from)
26702655
/*
26712656
* PRIMITIVE NODES
26722657
*/
2673-
caseT_Resdom:
2674-
retval=_copyResdom(from);
2675-
break;
26762658
caseT_Alias:
26772659
retval=_copyAlias(from);
26782660
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp