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

Commit43ba1b4

Browse files
committed
Add test code to copy all parse/plan trees. Repair essential omissions
in copyfuncs and equalfuncs exposed by regression tests. We still havesome work to do: these modules really ought to handle most or all ofthe utility statement node types. But it's better than it was.
1 parent6a7b40d commit43ba1b4

File tree

3 files changed

+200
-169
lines changed

3 files changed

+200
-169
lines changed

‎src/backend/nodes/copyfuncs.c

Lines changed: 82 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,23 @@
33
* copyfuncs.c
44
* Copy functions for Postgres tree nodes.
55
*
6+
* NOTE: a general convention when copying or comparing plan nodes is
7+
* that we ignore the executor state subnode. We do not need to look
8+
* at it because no current uses of copyObject() or equal() need to
9+
* deal with already-executing plan trees. By leaving the state subnodes
10+
* out, we avoid needing to write copy/compare routines for all the
11+
* different executor state node types.
12+
*
13+
* Another class of nodes not currently handled is nodes that appear
14+
* only in "raw" parsetrees (gram.y output not yet analyzed by the parser).
15+
* Perhaps some day that will need to be supported.
16+
*
17+
*
618
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
719
* Portions Copyright (c) 1994, Regents of the University of California
820
*
9-
*
1021
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.114 2000/06/18 22:44:05 tgl Exp $
22+
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.115 2000/06/29 07:35:56 tgl Exp $
1223
*
1324
*-------------------------------------------------------------------------
1425
*/
@@ -1671,9 +1682,6 @@ copyObject(void *from)
16711682
caseT_Agg:
16721683
retval=_copyAgg(from);
16731684
break;
1674-
caseT_GroupClause:
1675-
retval=_copyGroupClause(from);
1676-
break;
16771685
caseT_Unique:
16781686
retval=_copyUnique(from);
16791687
break;
@@ -1699,9 +1707,6 @@ copyObject(void *from)
16991707
caseT_Var:
17001708
retval=_copyVar(from);
17011709
break;
1702-
caseT_Attr:
1703-
retval=_copyAttr(from);
1704-
break;
17051710
caseT_Oper:
17061711
retval=_copyOper(from);
17071712
break;
@@ -1711,6 +1716,12 @@ copyObject(void *from)
17111716
caseT_Param:
17121717
retval=_copyParam(from);
17131718
break;
1719+
caseT_Aggref:
1720+
retval=_copyAggref(from);
1721+
break;
1722+
caseT_SubLink:
1723+
retval=_copySubLink(from);
1724+
break;
17141725
caseT_Func:
17151726
retval=_copyFunc(from);
17161727
break;
@@ -1720,21 +1731,12 @@ copyObject(void *from)
17201731
caseT_ArrayRef:
17211732
retval=_copyArrayRef(from);
17221733
break;
1723-
caseT_Aggref:
1724-
retval=_copyAggref(from);
1725-
break;
1726-
caseT_SubLink:
1727-
retval=_copySubLink(from);
1734+
caseT_Iter:
1735+
retval=_copyIter(from);
17281736
break;
17291737
caseT_RelabelType:
17301738
retval=_copyRelabelType(from);
17311739
break;
1732-
caseT_CaseExpr:
1733-
retval=_copyCaseExpr(from);
1734-
break;
1735-
caseT_CaseWhen:
1736-
retval=_copyCaseWhen(from);
1737-
break;
17381740

17391741
/*
17401742
* RELATION NODES
@@ -1769,9 +1771,6 @@ copyObject(void *from)
17691771
caseT_JoinInfo:
17701772
retval=_copyJoinInfo(from);
17711773
break;
1772-
caseT_Iter:
1773-
retval=_copyIter(from);
1774-
break;
17751774
caseT_Stream:
17761775
retval=_copyStream(from);
17771776
break;
@@ -1780,29 +1779,35 @@ copyObject(void *from)
17801779
break;
17811780

17821781
/*
1783-
*PARSE NODES
1782+
*VALUE NODES
17841783
*/
1785-
caseT_TargetEntry:
1786-
retval=_copyTargetEntry(from);
1787-
break;
1788-
caseT_RangeTblEntry:
1789-
retval=_copyRangeTblEntry(from);
1790-
break;
1791-
caseT_RowMark:
1792-
retval=_copyRowMark(from);
1793-
break;
1794-
caseT_SortClause:
1795-
retval=_copySortClause(from);
1796-
break;
1797-
caseT_A_Const:
1798-
retval=_copyAConst(from);
1799-
break;
1800-
caseT_TypeName:
1801-
retval=_copyTypeName(from);
1784+
caseT_Integer:
1785+
caseT_Float:
1786+
caseT_String:
1787+
retval=_copyValue(from);
18021788
break;
1803-
caseT_TypeCast:
1804-
retval=_copyTypeCast(from);
1789+
caseT_List:
1790+
{
1791+
List*list=from,
1792+
*l,
1793+
*nl;
1794+
1795+
/* rather ugly coding for speed... */
1796+
/* Note the input list cannot be NIL if we got here. */
1797+
nl=lcons(copyObject(lfirst(list)),NIL);
1798+
retval=nl;
1799+
1800+
foreach(l,lnext(list))
1801+
{
1802+
lnext(nl)=lcons(copyObject(lfirst(l)),NIL);
1803+
nl=lnext(nl);
1804+
}
1805+
}
18051806
break;
1807+
1808+
/*
1809+
* PARSE NODES
1810+
*/
18061811
caseT_Query:
18071812
retval=_copyQuery(from);
18081813
break;
@@ -1837,35 +1842,44 @@ copyObject(void *from)
18371842
retval=_copyLockStmt(from);
18381843
break;
18391844

1840-
/*
1841-
* VALUE NODES
1842-
*/
1843-
caseT_Integer:
1844-
caseT_Float:
1845-
caseT_String:
1846-
retval=_copyValue(from);
1845+
caseT_Attr:
1846+
retval=_copyAttr(from);
18471847
break;
1848-
caseT_List:
1849-
{
1850-
List*list=from,
1851-
*l,
1852-
*nl;
1853-
1854-
/* rather ugly coding for speed... */
1855-
/* Note the input list cannot be NIL if we got here. */
1856-
nl=lcons(copyObject(lfirst(list)),NIL);
1857-
retval=nl;
1858-
1859-
foreach(l,lnext(list))
1860-
{
1861-
lnext(nl)=lcons(copyObject(lfirst(l)),NIL);
1862-
nl=lnext(nl);
1863-
}
1864-
}
1848+
caseT_A_Const:
1849+
retval=_copyAConst(from);
1850+
break;
1851+
caseT_TypeCast:
1852+
retval=_copyTypeCast(from);
1853+
break;
1854+
caseT_TypeName:
1855+
retval=_copyTypeName(from);
1856+
break;
1857+
caseT_TargetEntry:
1858+
retval=_copyTargetEntry(from);
1859+
break;
1860+
caseT_RangeTblEntry:
1861+
retval=_copyRangeTblEntry(from);
18651862
break;
1863+
caseT_SortClause:
1864+
retval=_copySortClause(from);
1865+
break;
1866+
caseT_GroupClause:
1867+
retval=_copyGroupClause(from);
1868+
break;
1869+
caseT_CaseExpr:
1870+
retval=_copyCaseExpr(from);
1871+
break;
1872+
caseT_CaseWhen:
1873+
retval=_copyCaseWhen(from);
1874+
break;
1875+
caseT_RowMark:
1876+
retval=_copyRowMark(from);
1877+
break;
1878+
18661879
default:
1867-
elog(ERROR,"copyObject: don't know how to copy %d",nodeTag(from));
1868-
retval=from;
1880+
elog(ERROR,"copyObject: don't know how to copy node type %d",
1881+
nodeTag(from));
1882+
retval=from;/* keep compiler quiet */
18691883
break;
18701884
}
18711885
returnretval;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp