PageRenderTime 52ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 1ms

/src/backend/nodes/copyfuncs.c

https://github.com/bbt123/postgres
C | 4644 lines | 3299 code | 759 blank | 586 comment | 14 complexity | 52454c2b24489e3b9b1e6368764e2ef8 MD5 | raw file
Possible License(s): AGPL-3.0
  1. /*-------------------------------------------------------------------------
  2. *
  3. * copyfuncs.c
  4. * Copy functions for Postgres tree nodes.
  5. *
  6. * NOTE: we currently support copying all node types found in parse and
  7. * plan trees. We do not support copying executor state trees; there
  8. * is no need for that, and no point in maintaining all the code that
  9. * would be needed. We also do not support copying Path trees, mainly
  10. * because the circular linkages between RelOptInfo and Path nodes can't
  11. * be handled easily in a simple depth-first traversal.
  12. *
  13. *
  14. * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
  15. * Portions Copyright (c) 1994, Regents of the University of California
  16. *
  17. * IDENTIFICATION
  18. * src/backend/nodes/copyfuncs.c
  19. *
  20. *-------------------------------------------------------------------------
  21. */
  22. #include "postgres.h"
  23. #include "miscadmin.h"
  24. #include "nodes/plannodes.h"
  25. #include "nodes/relation.h"
  26. #include "utils/datum.h"
  27. /*
  28. * Macros to simplify copying of different kinds of fields. Use these
  29. * wherever possible to reduce the chance for silly typos. Note that these
  30. * hard-wire the convention that the local variables in a Copy routine are
  31. * named 'newnode' and 'from'.
  32. */
  33. /* Copy a simple scalar field (int, float, bool, enum, etc) */
  34. #define COPY_SCALAR_FIELD(fldname) \
  35. (newnode->fldname = from->fldname)
  36. /* Copy a field that is a pointer to some kind of Node or Node tree */
  37. #define COPY_NODE_FIELD(fldname) \
  38. (newnode->fldname = copyObject(from->fldname))
  39. /* Copy a field that is a pointer to a Bitmapset */
  40. #define COPY_BITMAPSET_FIELD(fldname) \
  41. (newnode->fldname = bms_copy(from->fldname))
  42. /* Copy a field that is a pointer to a C string, or perhaps NULL */
  43. #define COPY_STRING_FIELD(fldname) \
  44. (newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL)
  45. /* Copy a field that is a pointer to a simple palloc'd object of size sz */
  46. #define COPY_POINTER_FIELD(fldname, sz) \
  47. do { \
  48. Size _size = (sz); \
  49. newnode->fldname = palloc(_size); \
  50. memcpy(newnode->fldname, from->fldname, _size); \
  51. } while (0)
  52. /* Copy a parse location field (for Copy, this is same as scalar case) */
  53. #define COPY_LOCATION_FIELD(fldname) \
  54. (newnode->fldname = from->fldname)
  55. /* ****************************************************************
  56. * plannodes.h copy functions
  57. * ****************************************************************
  58. */
  59. /*
  60. * _copyPlannedStmt
  61. */
  62. static PlannedStmt *
  63. _copyPlannedStmt(const PlannedStmt *from)
  64. {
  65. PlannedStmt *newnode = makeNode(PlannedStmt);
  66. COPY_SCALAR_FIELD(commandType);
  67. COPY_SCALAR_FIELD(queryId);
  68. COPY_SCALAR_FIELD(hasReturning);
  69. COPY_SCALAR_FIELD(hasModifyingCTE);
  70. COPY_SCALAR_FIELD(canSetTag);
  71. COPY_SCALAR_FIELD(transientPlan);
  72. COPY_NODE_FIELD(planTree);
  73. COPY_NODE_FIELD(rtable);
  74. COPY_NODE_FIELD(resultRelations);
  75. COPY_NODE_FIELD(utilityStmt);
  76. COPY_NODE_FIELD(subplans);
  77. COPY_BITMAPSET_FIELD(rewindPlanIDs);
  78. COPY_NODE_FIELD(rowMarks);
  79. COPY_NODE_FIELD(relationOids);
  80. COPY_NODE_FIELD(invalItems);
  81. COPY_SCALAR_FIELD(nParamExec);
  82. return newnode;
  83. }
  84. /*
  85. * CopyPlanFields
  86. *
  87. * This function copies the fields of the Plan node. It is used by
  88. * all the copy functions for classes which inherit from Plan.
  89. */
  90. static void
  91. CopyPlanFields(const Plan *from, Plan *newnode)
  92. {
  93. COPY_SCALAR_FIELD(startup_cost);
  94. COPY_SCALAR_FIELD(total_cost);
  95. COPY_SCALAR_FIELD(plan_rows);
  96. COPY_SCALAR_FIELD(plan_width);
  97. COPY_NODE_FIELD(targetlist);
  98. COPY_NODE_FIELD(qual);
  99. COPY_NODE_FIELD(lefttree);
  100. COPY_NODE_FIELD(righttree);
  101. COPY_NODE_FIELD(initPlan);
  102. COPY_BITMAPSET_FIELD(extParam);
  103. COPY_BITMAPSET_FIELD(allParam);
  104. }
  105. /*
  106. * _copyPlan
  107. */
  108. static Plan *
  109. _copyPlan(const Plan *from)
  110. {
  111. Plan *newnode = makeNode(Plan);
  112. /*
  113. * copy node superclass fields
  114. */
  115. CopyPlanFields(from, newnode);
  116. return newnode;
  117. }
  118. /*
  119. * _copyResult
  120. */
  121. static Result *
  122. _copyResult(const Result *from)
  123. {
  124. Result *newnode = makeNode(Result);
  125. /*
  126. * copy node superclass fields
  127. */
  128. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  129. /*
  130. * copy remainder of node
  131. */
  132. COPY_NODE_FIELD(resconstantqual);
  133. return newnode;
  134. }
  135. /*
  136. * _copyModifyTable
  137. */
  138. static ModifyTable *
  139. _copyModifyTable(const ModifyTable *from)
  140. {
  141. ModifyTable *newnode = makeNode(ModifyTable);
  142. /*
  143. * copy node superclass fields
  144. */
  145. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  146. /*
  147. * copy remainder of node
  148. */
  149. COPY_SCALAR_FIELD(operation);
  150. COPY_SCALAR_FIELD(canSetTag);
  151. COPY_NODE_FIELD(resultRelations);
  152. COPY_SCALAR_FIELD(resultRelIndex);
  153. COPY_NODE_FIELD(plans);
  154. COPY_NODE_FIELD(withCheckOptionLists);
  155. COPY_NODE_FIELD(returningLists);
  156. COPY_NODE_FIELD(fdwPrivLists);
  157. COPY_NODE_FIELD(rowMarks);
  158. COPY_SCALAR_FIELD(epqParam);
  159. return newnode;
  160. }
  161. /*
  162. * _copyAppend
  163. */
  164. static Append *
  165. _copyAppend(const Append *from)
  166. {
  167. Append *newnode = makeNode(Append);
  168. /*
  169. * copy node superclass fields
  170. */
  171. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  172. /*
  173. * copy remainder of node
  174. */
  175. COPY_NODE_FIELD(appendplans);
  176. return newnode;
  177. }
  178. /*
  179. * _copyMergeAppend
  180. */
  181. static MergeAppend *
  182. _copyMergeAppend(const MergeAppend *from)
  183. {
  184. MergeAppend *newnode = makeNode(MergeAppend);
  185. /*
  186. * copy node superclass fields
  187. */
  188. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  189. /*
  190. * copy remainder of node
  191. */
  192. COPY_NODE_FIELD(mergeplans);
  193. COPY_SCALAR_FIELD(numCols);
  194. COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
  195. COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
  196. COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
  197. COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
  198. return newnode;
  199. }
  200. /*
  201. * _copyRecursiveUnion
  202. */
  203. static RecursiveUnion *
  204. _copyRecursiveUnion(const RecursiveUnion *from)
  205. {
  206. RecursiveUnion *newnode = makeNode(RecursiveUnion);
  207. /*
  208. * copy node superclass fields
  209. */
  210. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  211. /*
  212. * copy remainder of node
  213. */
  214. COPY_SCALAR_FIELD(wtParam);
  215. COPY_SCALAR_FIELD(numCols);
  216. if (from->numCols > 0)
  217. {
  218. COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
  219. COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
  220. }
  221. COPY_SCALAR_FIELD(numGroups);
  222. return newnode;
  223. }
  224. /*
  225. * _copyBitmapAnd
  226. */
  227. static BitmapAnd *
  228. _copyBitmapAnd(const BitmapAnd *from)
  229. {
  230. BitmapAnd *newnode = makeNode(BitmapAnd);
  231. /*
  232. * copy node superclass fields
  233. */
  234. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  235. /*
  236. * copy remainder of node
  237. */
  238. COPY_NODE_FIELD(bitmapplans);
  239. return newnode;
  240. }
  241. /*
  242. * _copyBitmapOr
  243. */
  244. static BitmapOr *
  245. _copyBitmapOr(const BitmapOr *from)
  246. {
  247. BitmapOr *newnode = makeNode(BitmapOr);
  248. /*
  249. * copy node superclass fields
  250. */
  251. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  252. /*
  253. * copy remainder of node
  254. */
  255. COPY_NODE_FIELD(bitmapplans);
  256. return newnode;
  257. }
  258. /*
  259. * CopyScanFields
  260. *
  261. * This function copies the fields of the Scan node. It is used by
  262. * all the copy functions for classes which inherit from Scan.
  263. */
  264. static void
  265. CopyScanFields(const Scan *from, Scan *newnode)
  266. {
  267. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  268. COPY_SCALAR_FIELD(scanrelid);
  269. }
  270. /*
  271. * _copyScan
  272. */
  273. static Scan *
  274. _copyScan(const Scan *from)
  275. {
  276. Scan *newnode = makeNode(Scan);
  277. /*
  278. * copy node superclass fields
  279. */
  280. CopyScanFields((const Scan *) from, (Scan *) newnode);
  281. return newnode;
  282. }
  283. /*
  284. * _copySeqScan
  285. */
  286. static SeqScan *
  287. _copySeqScan(const SeqScan *from)
  288. {
  289. SeqScan *newnode = makeNode(SeqScan);
  290. /*
  291. * copy node superclass fields
  292. */
  293. CopyScanFields((const Scan *) from, (Scan *) newnode);
  294. return newnode;
  295. }
  296. /*
  297. * _copyIndexScan
  298. */
  299. static IndexScan *
  300. _copyIndexScan(const IndexScan *from)
  301. {
  302. IndexScan *newnode = makeNode(IndexScan);
  303. /*
  304. * copy node superclass fields
  305. */
  306. CopyScanFields((const Scan *) from, (Scan *) newnode);
  307. /*
  308. * copy remainder of node
  309. */
  310. COPY_SCALAR_FIELD(indexid);
  311. COPY_NODE_FIELD(indexqual);
  312. COPY_NODE_FIELD(indexqualorig);
  313. COPY_NODE_FIELD(indexorderby);
  314. COPY_NODE_FIELD(indexorderbyorig);
  315. COPY_SCALAR_FIELD(indexorderdir);
  316. return newnode;
  317. }
  318. /*
  319. * _copyIndexOnlyScan
  320. */
  321. static IndexOnlyScan *
  322. _copyIndexOnlyScan(const IndexOnlyScan *from)
  323. {
  324. IndexOnlyScan *newnode = makeNode(IndexOnlyScan);
  325. /*
  326. * copy node superclass fields
  327. */
  328. CopyScanFields((const Scan *) from, (Scan *) newnode);
  329. /*
  330. * copy remainder of node
  331. */
  332. COPY_SCALAR_FIELD(indexid);
  333. COPY_NODE_FIELD(indexqual);
  334. COPY_NODE_FIELD(indexorderby);
  335. COPY_NODE_FIELD(indextlist);
  336. COPY_SCALAR_FIELD(indexorderdir);
  337. return newnode;
  338. }
  339. /*
  340. * _copyBitmapIndexScan
  341. */
  342. static BitmapIndexScan *
  343. _copyBitmapIndexScan(const BitmapIndexScan *from)
  344. {
  345. BitmapIndexScan *newnode = makeNode(BitmapIndexScan);
  346. /*
  347. * copy node superclass fields
  348. */
  349. CopyScanFields((const Scan *) from, (Scan *) newnode);
  350. /*
  351. * copy remainder of node
  352. */
  353. COPY_SCALAR_FIELD(indexid);
  354. COPY_NODE_FIELD(indexqual);
  355. COPY_NODE_FIELD(indexqualorig);
  356. return newnode;
  357. }
  358. /*
  359. * _copyBitmapHeapScan
  360. */
  361. static BitmapHeapScan *
  362. _copyBitmapHeapScan(const BitmapHeapScan *from)
  363. {
  364. BitmapHeapScan *newnode = makeNode(BitmapHeapScan);
  365. /*
  366. * copy node superclass fields
  367. */
  368. CopyScanFields((const Scan *) from, (Scan *) newnode);
  369. /*
  370. * copy remainder of node
  371. */
  372. COPY_NODE_FIELD(bitmapqualorig);
  373. return newnode;
  374. }
  375. /*
  376. * _copyTidScan
  377. */
  378. static TidScan *
  379. _copyTidScan(const TidScan *from)
  380. {
  381. TidScan *newnode = makeNode(TidScan);
  382. /*
  383. * copy node superclass fields
  384. */
  385. CopyScanFields((const Scan *) from, (Scan *) newnode);
  386. /*
  387. * copy remainder of node
  388. */
  389. COPY_NODE_FIELD(tidquals);
  390. return newnode;
  391. }
  392. /*
  393. * _copySubqueryScan
  394. */
  395. static SubqueryScan *
  396. _copySubqueryScan(const SubqueryScan *from)
  397. {
  398. SubqueryScan *newnode = makeNode(SubqueryScan);
  399. /*
  400. * copy node superclass fields
  401. */
  402. CopyScanFields((const Scan *) from, (Scan *) newnode);
  403. /*
  404. * copy remainder of node
  405. */
  406. COPY_NODE_FIELD(subplan);
  407. return newnode;
  408. }
  409. /*
  410. * _copyFunctionScan
  411. */
  412. static FunctionScan *
  413. _copyFunctionScan(const FunctionScan *from)
  414. {
  415. FunctionScan *newnode = makeNode(FunctionScan);
  416. /*
  417. * copy node superclass fields
  418. */
  419. CopyScanFields((const Scan *) from, (Scan *) newnode);
  420. /*
  421. * copy remainder of node
  422. */
  423. COPY_NODE_FIELD(functions);
  424. COPY_SCALAR_FIELD(funcordinality);
  425. return newnode;
  426. }
  427. /*
  428. * _copyValuesScan
  429. */
  430. static ValuesScan *
  431. _copyValuesScan(const ValuesScan *from)
  432. {
  433. ValuesScan *newnode = makeNode(ValuesScan);
  434. /*
  435. * copy node superclass fields
  436. */
  437. CopyScanFields((const Scan *) from, (Scan *) newnode);
  438. /*
  439. * copy remainder of node
  440. */
  441. COPY_NODE_FIELD(values_lists);
  442. return newnode;
  443. }
  444. /*
  445. * _copyCteScan
  446. */
  447. static CteScan *
  448. _copyCteScan(const CteScan *from)
  449. {
  450. CteScan *newnode = makeNode(CteScan);
  451. /*
  452. * copy node superclass fields
  453. */
  454. CopyScanFields((const Scan *) from, (Scan *) newnode);
  455. /*
  456. * copy remainder of node
  457. */
  458. COPY_SCALAR_FIELD(ctePlanId);
  459. COPY_SCALAR_FIELD(cteParam);
  460. return newnode;
  461. }
  462. /*
  463. * _copyWorkTableScan
  464. */
  465. static WorkTableScan *
  466. _copyWorkTableScan(const WorkTableScan *from)
  467. {
  468. WorkTableScan *newnode = makeNode(WorkTableScan);
  469. /*
  470. * copy node superclass fields
  471. */
  472. CopyScanFields((const Scan *) from, (Scan *) newnode);
  473. /*
  474. * copy remainder of node
  475. */
  476. COPY_SCALAR_FIELD(wtParam);
  477. return newnode;
  478. }
  479. /*
  480. * _copyForeignScan
  481. */
  482. static ForeignScan *
  483. _copyForeignScan(const ForeignScan *from)
  484. {
  485. ForeignScan *newnode = makeNode(ForeignScan);
  486. /*
  487. * copy node superclass fields
  488. */
  489. CopyScanFields((const Scan *) from, (Scan *) newnode);
  490. /*
  491. * copy remainder of node
  492. */
  493. COPY_NODE_FIELD(fdw_exprs);
  494. COPY_NODE_FIELD(fdw_private);
  495. COPY_SCALAR_FIELD(fsSystemCol);
  496. return newnode;
  497. }
  498. /*
  499. * CopyJoinFields
  500. *
  501. * This function copies the fields of the Join node. It is used by
  502. * all the copy functions for classes which inherit from Join.
  503. */
  504. static void
  505. CopyJoinFields(const Join *from, Join *newnode)
  506. {
  507. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  508. COPY_SCALAR_FIELD(jointype);
  509. COPY_NODE_FIELD(joinqual);
  510. }
  511. /*
  512. * _copyJoin
  513. */
  514. static Join *
  515. _copyJoin(const Join *from)
  516. {
  517. Join *newnode = makeNode(Join);
  518. /*
  519. * copy node superclass fields
  520. */
  521. CopyJoinFields(from, newnode);
  522. return newnode;
  523. }
  524. /*
  525. * _copyNestLoop
  526. */
  527. static NestLoop *
  528. _copyNestLoop(const NestLoop *from)
  529. {
  530. NestLoop *newnode = makeNode(NestLoop);
  531. /*
  532. * copy node superclass fields
  533. */
  534. CopyJoinFields((const Join *) from, (Join *) newnode);
  535. /*
  536. * copy remainder of node
  537. */
  538. COPY_NODE_FIELD(nestParams);
  539. return newnode;
  540. }
  541. /*
  542. * _copyMergeJoin
  543. */
  544. static MergeJoin *
  545. _copyMergeJoin(const MergeJoin *from)
  546. {
  547. MergeJoin *newnode = makeNode(MergeJoin);
  548. int numCols;
  549. /*
  550. * copy node superclass fields
  551. */
  552. CopyJoinFields((const Join *) from, (Join *) newnode);
  553. /*
  554. * copy remainder of node
  555. */
  556. COPY_NODE_FIELD(mergeclauses);
  557. numCols = list_length(from->mergeclauses);
  558. if (numCols > 0)
  559. {
  560. COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
  561. COPY_POINTER_FIELD(mergeCollations, numCols * sizeof(Oid));
  562. COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
  563. COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
  564. }
  565. return newnode;
  566. }
  567. /*
  568. * _copyHashJoin
  569. */
  570. static HashJoin *
  571. _copyHashJoin(const HashJoin *from)
  572. {
  573. HashJoin *newnode = makeNode(HashJoin);
  574. /*
  575. * copy node superclass fields
  576. */
  577. CopyJoinFields((const Join *) from, (Join *) newnode);
  578. /*
  579. * copy remainder of node
  580. */
  581. COPY_NODE_FIELD(hashclauses);
  582. return newnode;
  583. }
  584. /*
  585. * _copyMaterial
  586. */
  587. static Material *
  588. _copyMaterial(const Material *from)
  589. {
  590. Material *newnode = makeNode(Material);
  591. /*
  592. * copy node superclass fields
  593. */
  594. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  595. return newnode;
  596. }
  597. /*
  598. * _copySort
  599. */
  600. static Sort *
  601. _copySort(const Sort *from)
  602. {
  603. Sort *newnode = makeNode(Sort);
  604. /*
  605. * copy node superclass fields
  606. */
  607. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  608. COPY_SCALAR_FIELD(numCols);
  609. COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
  610. COPY_POINTER_FIELD(sortOperators, from->numCols * sizeof(Oid));
  611. COPY_POINTER_FIELD(collations, from->numCols * sizeof(Oid));
  612. COPY_POINTER_FIELD(nullsFirst, from->numCols * sizeof(bool));
  613. return newnode;
  614. }
  615. /*
  616. * _copyGroup
  617. */
  618. static Group *
  619. _copyGroup(const Group *from)
  620. {
  621. Group *newnode = makeNode(Group);
  622. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  623. COPY_SCALAR_FIELD(numCols);
  624. COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
  625. COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
  626. return newnode;
  627. }
  628. /*
  629. * _copyAgg
  630. */
  631. static Agg *
  632. _copyAgg(const Agg *from)
  633. {
  634. Agg *newnode = makeNode(Agg);
  635. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  636. COPY_SCALAR_FIELD(aggstrategy);
  637. COPY_SCALAR_FIELD(numCols);
  638. if (from->numCols > 0)
  639. {
  640. COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
  641. COPY_POINTER_FIELD(grpOperators, from->numCols * sizeof(Oid));
  642. }
  643. COPY_SCALAR_FIELD(numGroups);
  644. return newnode;
  645. }
  646. /*
  647. * _copyWindowAgg
  648. */
  649. static WindowAgg *
  650. _copyWindowAgg(const WindowAgg *from)
  651. {
  652. WindowAgg *newnode = makeNode(WindowAgg);
  653. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  654. COPY_SCALAR_FIELD(winref);
  655. COPY_SCALAR_FIELD(partNumCols);
  656. if (from->partNumCols > 0)
  657. {
  658. COPY_POINTER_FIELD(partColIdx, from->partNumCols * sizeof(AttrNumber));
  659. COPY_POINTER_FIELD(partOperators, from->partNumCols * sizeof(Oid));
  660. }
  661. COPY_SCALAR_FIELD(ordNumCols);
  662. if (from->ordNumCols > 0)
  663. {
  664. COPY_POINTER_FIELD(ordColIdx, from->ordNumCols * sizeof(AttrNumber));
  665. COPY_POINTER_FIELD(ordOperators, from->ordNumCols * sizeof(Oid));
  666. }
  667. COPY_SCALAR_FIELD(frameOptions);
  668. COPY_NODE_FIELD(startOffset);
  669. COPY_NODE_FIELD(endOffset);
  670. return newnode;
  671. }
  672. /*
  673. * _copyUnique
  674. */
  675. static Unique *
  676. _copyUnique(const Unique *from)
  677. {
  678. Unique *newnode = makeNode(Unique);
  679. /*
  680. * copy node superclass fields
  681. */
  682. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  683. /*
  684. * copy remainder of node
  685. */
  686. COPY_SCALAR_FIELD(numCols);
  687. COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
  688. COPY_POINTER_FIELD(uniqOperators, from->numCols * sizeof(Oid));
  689. return newnode;
  690. }
  691. /*
  692. * _copyHash
  693. */
  694. static Hash *
  695. _copyHash(const Hash *from)
  696. {
  697. Hash *newnode = makeNode(Hash);
  698. /*
  699. * copy node superclass fields
  700. */
  701. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  702. /*
  703. * copy remainder of node
  704. */
  705. COPY_SCALAR_FIELD(skewTable);
  706. COPY_SCALAR_FIELD(skewColumn);
  707. COPY_SCALAR_FIELD(skewInherit);
  708. COPY_SCALAR_FIELD(skewColType);
  709. COPY_SCALAR_FIELD(skewColTypmod);
  710. return newnode;
  711. }
  712. /*
  713. * _copySetOp
  714. */
  715. static SetOp *
  716. _copySetOp(const SetOp *from)
  717. {
  718. SetOp *newnode = makeNode(SetOp);
  719. /*
  720. * copy node superclass fields
  721. */
  722. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  723. /*
  724. * copy remainder of node
  725. */
  726. COPY_SCALAR_FIELD(cmd);
  727. COPY_SCALAR_FIELD(strategy);
  728. COPY_SCALAR_FIELD(numCols);
  729. COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
  730. COPY_POINTER_FIELD(dupOperators, from->numCols * sizeof(Oid));
  731. COPY_SCALAR_FIELD(flagColIdx);
  732. COPY_SCALAR_FIELD(firstFlag);
  733. COPY_SCALAR_FIELD(numGroups);
  734. return newnode;
  735. }
  736. /*
  737. * _copyLockRows
  738. */
  739. static LockRows *
  740. _copyLockRows(const LockRows *from)
  741. {
  742. LockRows *newnode = makeNode(LockRows);
  743. /*
  744. * copy node superclass fields
  745. */
  746. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  747. /*
  748. * copy remainder of node
  749. */
  750. COPY_NODE_FIELD(rowMarks);
  751. COPY_SCALAR_FIELD(epqParam);
  752. return newnode;
  753. }
  754. /*
  755. * _copyLimit
  756. */
  757. static Limit *
  758. _copyLimit(const Limit *from)
  759. {
  760. Limit *newnode = makeNode(Limit);
  761. /*
  762. * copy node superclass fields
  763. */
  764. CopyPlanFields((const Plan *) from, (Plan *) newnode);
  765. /*
  766. * copy remainder of node
  767. */
  768. COPY_NODE_FIELD(limitOffset);
  769. COPY_NODE_FIELD(limitCount);
  770. return newnode;
  771. }
  772. /*
  773. * _copyNestLoopParam
  774. */
  775. static NestLoopParam *
  776. _copyNestLoopParam(const NestLoopParam *from)
  777. {
  778. NestLoopParam *newnode = makeNode(NestLoopParam);
  779. COPY_SCALAR_FIELD(paramno);
  780. COPY_NODE_FIELD(paramval);
  781. return newnode;
  782. }
  783. /*
  784. * _copyPlanRowMark
  785. */
  786. static PlanRowMark *
  787. _copyPlanRowMark(const PlanRowMark *from)
  788. {
  789. PlanRowMark *newnode = makeNode(PlanRowMark);
  790. COPY_SCALAR_FIELD(rti);
  791. COPY_SCALAR_FIELD(prti);
  792. COPY_SCALAR_FIELD(rowmarkId);
  793. COPY_SCALAR_FIELD(markType);
  794. COPY_SCALAR_FIELD(noWait);
  795. COPY_SCALAR_FIELD(isParent);
  796. return newnode;
  797. }
  798. /*
  799. * _copyPlanInvalItem
  800. */
  801. static PlanInvalItem *
  802. _copyPlanInvalItem(const PlanInvalItem *from)
  803. {
  804. PlanInvalItem *newnode = makeNode(PlanInvalItem);
  805. COPY_SCALAR_FIELD(cacheId);
  806. COPY_SCALAR_FIELD(hashValue);
  807. return newnode;
  808. }
  809. /* ****************************************************************
  810. * primnodes.h copy functions
  811. * ****************************************************************
  812. */
  813. /*
  814. * _copyAlias
  815. */
  816. static Alias *
  817. _copyAlias(const Alias *from)
  818. {
  819. Alias *newnode = makeNode(Alias);
  820. COPY_STRING_FIELD(aliasname);
  821. COPY_NODE_FIELD(colnames);
  822. return newnode;
  823. }
  824. /*
  825. * _copyRangeVar
  826. */
  827. static RangeVar *
  828. _copyRangeVar(const RangeVar *from)
  829. {
  830. RangeVar *newnode = makeNode(RangeVar);
  831. COPY_STRING_FIELD(catalogname);
  832. COPY_STRING_FIELD(schemaname);
  833. COPY_STRING_FIELD(relname);
  834. COPY_SCALAR_FIELD(inhOpt);
  835. COPY_SCALAR_FIELD(relpersistence);
  836. COPY_NODE_FIELD(alias);
  837. COPY_LOCATION_FIELD(location);
  838. return newnode;
  839. }
  840. /*
  841. * _copyIntoClause
  842. */
  843. static IntoClause *
  844. _copyIntoClause(const IntoClause *from)
  845. {
  846. IntoClause *newnode = makeNode(IntoClause);
  847. COPY_NODE_FIELD(rel);
  848. COPY_NODE_FIELD(colNames);
  849. COPY_NODE_FIELD(options);
  850. COPY_SCALAR_FIELD(onCommit);
  851. COPY_STRING_FIELD(tableSpaceName);
  852. COPY_NODE_FIELD(viewQuery);
  853. COPY_SCALAR_FIELD(skipData);
  854. return newnode;
  855. }
  856. /*
  857. * We don't need a _copyExpr because Expr is an abstract supertype which
  858. * should never actually get instantiated. Also, since it has no common
  859. * fields except NodeTag, there's no need for a helper routine to factor
  860. * out copying the common fields...
  861. */
  862. /*
  863. * _copyVar
  864. */
  865. static Var *
  866. _copyVar(const Var *from)
  867. {
  868. Var *newnode = makeNode(Var);
  869. COPY_SCALAR_FIELD(varno);
  870. COPY_SCALAR_FIELD(varattno);
  871. COPY_SCALAR_FIELD(vartype);
  872. COPY_SCALAR_FIELD(vartypmod);
  873. COPY_SCALAR_FIELD(varcollid);
  874. COPY_SCALAR_FIELD(varlevelsup);
  875. COPY_SCALAR_FIELD(varnoold);
  876. COPY_SCALAR_FIELD(varoattno);
  877. COPY_LOCATION_FIELD(location);
  878. return newnode;
  879. }
  880. /*
  881. * _copyConst
  882. */
  883. static Const *
  884. _copyConst(const Const *from)
  885. {
  886. Const *newnode = makeNode(Const);
  887. COPY_SCALAR_FIELD(consttype);
  888. COPY_SCALAR_FIELD(consttypmod);
  889. COPY_SCALAR_FIELD(constcollid);
  890. COPY_SCALAR_FIELD(constlen);
  891. if (from->constbyval || from->constisnull)
  892. {
  893. /*
  894. * passed by value so just copy the datum. Also, don't try to copy
  895. * struct when value is null!
  896. */
  897. newnode->constvalue = from->constvalue;
  898. }
  899. else
  900. {
  901. /*
  902. * passed by reference. We need a palloc'd copy.
  903. */
  904. newnode->constvalue = datumCopy(from->constvalue,
  905. from->constbyval,
  906. from->constlen);
  907. }
  908. COPY_SCALAR_FIELD(constisnull);
  909. COPY_SCALAR_FIELD(constbyval);
  910. COPY_LOCATION_FIELD(location);
  911. return newnode;
  912. }
  913. /*
  914. * _copyParam
  915. */
  916. static Param *
  917. _copyParam(const Param *from)
  918. {
  919. Param *newnode = makeNode(Param);
  920. COPY_SCALAR_FIELD(paramkind);
  921. COPY_SCALAR_FIELD(paramid);
  922. COPY_SCALAR_FIELD(paramtype);
  923. COPY_SCALAR_FIELD(paramtypmod);
  924. COPY_SCALAR_FIELD(paramcollid);
  925. COPY_LOCATION_FIELD(location);
  926. return newnode;
  927. }
  928. /*
  929. * _copyAggref
  930. */
  931. static Aggref *
  932. _copyAggref(const Aggref *from)
  933. {
  934. Aggref *newnode = makeNode(Aggref);
  935. COPY_SCALAR_FIELD(aggfnoid);
  936. COPY_SCALAR_FIELD(aggtype);
  937. COPY_SCALAR_FIELD(aggcollid);
  938. COPY_SCALAR_FIELD(inputcollid);
  939. COPY_NODE_FIELD(aggdirectargs);
  940. COPY_NODE_FIELD(args);
  941. COPY_NODE_FIELD(aggorder);
  942. COPY_NODE_FIELD(aggdistinct);
  943. COPY_NODE_FIELD(aggfilter);
  944. COPY_SCALAR_FIELD(aggstar);
  945. COPY_SCALAR_FIELD(aggvariadic);
  946. COPY_SCALAR_FIELD(aggkind);
  947. COPY_SCALAR_FIELD(agglevelsup);
  948. COPY_LOCATION_FIELD(location);
  949. return newnode;
  950. }
  951. /*
  952. * _copyWindowFunc
  953. */
  954. static WindowFunc *
  955. _copyWindowFunc(const WindowFunc *from)
  956. {
  957. WindowFunc *newnode = makeNode(WindowFunc);
  958. COPY_SCALAR_FIELD(winfnoid);
  959. COPY_SCALAR_FIELD(wintype);
  960. COPY_SCALAR_FIELD(wincollid);
  961. COPY_SCALAR_FIELD(inputcollid);
  962. COPY_NODE_FIELD(args);
  963. COPY_NODE_FIELD(aggfilter);
  964. COPY_SCALAR_FIELD(winref);
  965. COPY_SCALAR_FIELD(winstar);
  966. COPY_SCALAR_FIELD(winagg);
  967. COPY_LOCATION_FIELD(location);
  968. return newnode;
  969. }
  970. /*
  971. * _copyArrayRef
  972. */
  973. static ArrayRef *
  974. _copyArrayRef(const ArrayRef *from)
  975. {
  976. ArrayRef *newnode = makeNode(ArrayRef);
  977. COPY_SCALAR_FIELD(refarraytype);
  978. COPY_SCALAR_FIELD(refelemtype);
  979. COPY_SCALAR_FIELD(reftypmod);
  980. COPY_SCALAR_FIELD(refcollid);
  981. COPY_NODE_FIELD(refupperindexpr);
  982. COPY_NODE_FIELD(reflowerindexpr);
  983. COPY_NODE_FIELD(refexpr);
  984. COPY_NODE_FIELD(refassgnexpr);
  985. return newnode;
  986. }
  987. /*
  988. * _copyFuncExpr
  989. */
  990. static FuncExpr *
  991. _copyFuncExpr(const FuncExpr *from)
  992. {
  993. FuncExpr *newnode = makeNode(FuncExpr);
  994. COPY_SCALAR_FIELD(funcid);
  995. COPY_SCALAR_FIELD(funcresulttype);
  996. COPY_SCALAR_FIELD(funcretset);
  997. COPY_SCALAR_FIELD(funcvariadic);
  998. COPY_SCALAR_FIELD(funcformat);
  999. COPY_SCALAR_FIELD(funccollid);
  1000. COPY_SCALAR_FIELD(inputcollid);
  1001. COPY_NODE_FIELD(args);
  1002. COPY_LOCATION_FIELD(location);
  1003. return newnode;
  1004. }
  1005. /*
  1006. * _copyNamedArgExpr *
  1007. */
  1008. static NamedArgExpr *
  1009. _copyNamedArgExpr(const NamedArgExpr *from)
  1010. {
  1011. NamedArgExpr *newnode = makeNode(NamedArgExpr);
  1012. COPY_NODE_FIELD(arg);
  1013. COPY_STRING_FIELD(name);
  1014. COPY_SCALAR_FIELD(argnumber);
  1015. COPY_LOCATION_FIELD(location);
  1016. return newnode;
  1017. }
  1018. /*
  1019. * _copyOpExpr
  1020. */
  1021. static OpExpr *
  1022. _copyOpExpr(const OpExpr *from)
  1023. {
  1024. OpExpr *newnode = makeNode(OpExpr);
  1025. COPY_SCALAR_FIELD(opno);
  1026. COPY_SCALAR_FIELD(opfuncid);
  1027. COPY_SCALAR_FIELD(opresulttype);
  1028. COPY_SCALAR_FIELD(opretset);
  1029. COPY_SCALAR_FIELD(opcollid);
  1030. COPY_SCALAR_FIELD(inputcollid);
  1031. COPY_NODE_FIELD(args);
  1032. COPY_LOCATION_FIELD(location);
  1033. return newnode;
  1034. }
  1035. /*
  1036. * _copyDistinctExpr (same as OpExpr)
  1037. */
  1038. static DistinctExpr *
  1039. _copyDistinctExpr(const DistinctExpr *from)
  1040. {
  1041. DistinctExpr *newnode = makeNode(DistinctExpr);
  1042. COPY_SCALAR_FIELD(opno);
  1043. COPY_SCALAR_FIELD(opfuncid);
  1044. COPY_SCALAR_FIELD(opresulttype);
  1045. COPY_SCALAR_FIELD(opretset);
  1046. COPY_SCALAR_FIELD(opcollid);
  1047. COPY_SCALAR_FIELD(inputcollid);
  1048. COPY_NODE_FIELD(args);
  1049. COPY_LOCATION_FIELD(location);
  1050. return newnode;
  1051. }
  1052. /*
  1053. * _copyNullIfExpr (same as OpExpr)
  1054. */
  1055. static NullIfExpr *
  1056. _copyNullIfExpr(const NullIfExpr *from)
  1057. {
  1058. NullIfExpr *newnode = makeNode(NullIfExpr);
  1059. COPY_SCALAR_FIELD(opno);
  1060. COPY_SCALAR_FIELD(opfuncid);
  1061. COPY_SCALAR_FIELD(opresulttype);
  1062. COPY_SCALAR_FIELD(opretset);
  1063. COPY_SCALAR_FIELD(opcollid);
  1064. COPY_SCALAR_FIELD(inputcollid);
  1065. COPY_NODE_FIELD(args);
  1066. COPY_LOCATION_FIELD(location);
  1067. return newnode;
  1068. }
  1069. /*
  1070. * _copyScalarArrayOpExpr
  1071. */
  1072. static ScalarArrayOpExpr *
  1073. _copyScalarArrayOpExpr(const ScalarArrayOpExpr *from)
  1074. {
  1075. ScalarArrayOpExpr *newnode = makeNode(ScalarArrayOpExpr);
  1076. COPY_SCALAR_FIELD(opno);
  1077. COPY_SCALAR_FIELD(opfuncid);
  1078. COPY_SCALAR_FIELD(useOr);
  1079. COPY_SCALAR_FIELD(inputcollid);
  1080. COPY_NODE_FIELD(args);
  1081. COPY_LOCATION_FIELD(location);
  1082. return newnode;
  1083. }
  1084. /*
  1085. * _copyBoolExpr
  1086. */
  1087. static BoolExpr *
  1088. _copyBoolExpr(const BoolExpr *from)
  1089. {
  1090. BoolExpr *newnode = makeNode(BoolExpr);
  1091. COPY_SCALAR_FIELD(boolop);
  1092. COPY_NODE_FIELD(args);
  1093. COPY_LOCATION_FIELD(location);
  1094. return newnode;
  1095. }
  1096. /*
  1097. * _copySubLink
  1098. */
  1099. static SubLink *
  1100. _copySubLink(const SubLink *from)
  1101. {
  1102. SubLink *newnode = makeNode(SubLink);
  1103. COPY_SCALAR_FIELD(subLinkType);
  1104. COPY_NODE_FIELD(testexpr);
  1105. COPY_NODE_FIELD(operName);
  1106. COPY_NODE_FIELD(subselect);
  1107. COPY_LOCATION_FIELD(location);
  1108. return newnode;
  1109. }
  1110. /*
  1111. * _copySubPlan
  1112. */
  1113. static SubPlan *
  1114. _copySubPlan(const SubPlan *from)
  1115. {
  1116. SubPlan *newnode = makeNode(SubPlan);
  1117. COPY_SCALAR_FIELD(subLinkType);
  1118. COPY_NODE_FIELD(testexpr);
  1119. COPY_NODE_FIELD(paramIds);
  1120. COPY_SCALAR_FIELD(plan_id);
  1121. COPY_STRING_FIELD(plan_name);
  1122. COPY_SCALAR_FIELD(firstColType);
  1123. COPY_SCALAR_FIELD(firstColTypmod);
  1124. COPY_SCALAR_FIELD(firstColCollation);
  1125. COPY_SCALAR_FIELD(useHashTable);
  1126. COPY_SCALAR_FIELD(unknownEqFalse);
  1127. COPY_NODE_FIELD(setParam);
  1128. COPY_NODE_FIELD(parParam);
  1129. COPY_NODE_FIELD(args);
  1130. COPY_SCALAR_FIELD(startup_cost);
  1131. COPY_SCALAR_FIELD(per_call_cost);
  1132. return newnode;
  1133. }
  1134. /*
  1135. * _copyAlternativeSubPlan
  1136. */
  1137. static AlternativeSubPlan *
  1138. _copyAlternativeSubPlan(const AlternativeSubPlan *from)
  1139. {
  1140. AlternativeSubPlan *newnode = makeNode(AlternativeSubPlan);
  1141. COPY_NODE_FIELD(subplans);
  1142. return newnode;
  1143. }
  1144. /*
  1145. * _copyFieldSelect
  1146. */
  1147. static FieldSelect *
  1148. _copyFieldSelect(const FieldSelect *from)
  1149. {
  1150. FieldSelect *newnode = makeNode(FieldSelect);
  1151. COPY_NODE_FIELD(arg);
  1152. COPY_SCALAR_FIELD(fieldnum);
  1153. COPY_SCALAR_FIELD(resulttype);
  1154. COPY_SCALAR_FIELD(resulttypmod);
  1155. COPY_SCALAR_FIELD(resultcollid);
  1156. return newnode;
  1157. }
  1158. /*
  1159. * _copyFieldStore
  1160. */
  1161. static FieldStore *
  1162. _copyFieldStore(const FieldStore *from)
  1163. {
  1164. FieldStore *newnode = makeNode(FieldStore);
  1165. COPY_NODE_FIELD(arg);
  1166. COPY_NODE_FIELD(newvals);
  1167. COPY_NODE_FIELD(fieldnums);
  1168. COPY_SCALAR_FIELD(resulttype);
  1169. return newnode;
  1170. }
  1171. /*
  1172. * _copyRelabelType
  1173. */
  1174. static RelabelType *
  1175. _copyRelabelType(const RelabelType *from)
  1176. {
  1177. RelabelType *newnode = makeNode(RelabelType);
  1178. COPY_NODE_FIELD(arg);
  1179. COPY_SCALAR_FIELD(resulttype);
  1180. COPY_SCALAR_FIELD(resulttypmod);
  1181. COPY_SCALAR_FIELD(resultcollid);
  1182. COPY_SCALAR_FIELD(relabelformat);
  1183. COPY_LOCATION_FIELD(location);
  1184. return newnode;
  1185. }
  1186. /*
  1187. * _copyCoerceViaIO
  1188. */
  1189. static CoerceViaIO *
  1190. _copyCoerceViaIO(const CoerceViaIO *from)
  1191. {
  1192. CoerceViaIO *newnode = makeNode(CoerceViaIO);
  1193. COPY_NODE_FIELD(arg);
  1194. COPY_SCALAR_FIELD(resulttype);
  1195. COPY_SCALAR_FIELD(resultcollid);
  1196. COPY_SCALAR_FIELD(coerceformat);
  1197. COPY_LOCATION_FIELD(location);
  1198. return newnode;
  1199. }
  1200. /*
  1201. * _copyArrayCoerceExpr
  1202. */
  1203. static ArrayCoerceExpr *
  1204. _copyArrayCoerceExpr(const ArrayCoerceExpr *from)
  1205. {
  1206. ArrayCoerceExpr *newnode = makeNode(ArrayCoerceExpr);
  1207. COPY_NODE_FIELD(arg);
  1208. COPY_SCALAR_FIELD(elemfuncid);
  1209. COPY_SCALAR_FIELD(resulttype);
  1210. COPY_SCALAR_FIELD(resulttypmod);
  1211. COPY_SCALAR_FIELD(resultcollid);
  1212. COPY_SCALAR_FIELD(isExplicit);
  1213. COPY_SCALAR_FIELD(coerceformat);
  1214. COPY_LOCATION_FIELD(location);
  1215. return newnode;
  1216. }
  1217. /*
  1218. * _copyConvertRowtypeExpr
  1219. */
  1220. static ConvertRowtypeExpr *
  1221. _copyConvertRowtypeExpr(const ConvertRowtypeExpr *from)
  1222. {
  1223. ConvertRowtypeExpr *newnode = makeNode(ConvertRowtypeExpr);
  1224. COPY_NODE_FIELD(arg);
  1225. COPY_SCALAR_FIELD(resulttype);
  1226. COPY_SCALAR_FIELD(convertformat);
  1227. COPY_LOCATION_FIELD(location);
  1228. return newnode;
  1229. }
  1230. /*
  1231. * _copyCollateExpr
  1232. */
  1233. static CollateExpr *
  1234. _copyCollateExpr(const CollateExpr *from)
  1235. {
  1236. CollateExpr *newnode = makeNode(CollateExpr);
  1237. COPY_NODE_FIELD(arg);
  1238. COPY_SCALAR_FIELD(collOid);
  1239. COPY_LOCATION_FIELD(location);
  1240. return newnode;
  1241. }
  1242. /*
  1243. * _copyCaseExpr
  1244. */
  1245. static CaseExpr *
  1246. _copyCaseExpr(const CaseExpr *from)
  1247. {
  1248. CaseExpr *newnode = makeNode(CaseExpr);
  1249. COPY_SCALAR_FIELD(casetype);
  1250. COPY_SCALAR_FIELD(casecollid);
  1251. COPY_NODE_FIELD(arg);
  1252. COPY_NODE_FIELD(args);
  1253. COPY_NODE_FIELD(defresult);
  1254. COPY_LOCATION_FIELD(location);
  1255. return newnode;
  1256. }
  1257. /*
  1258. * _copyCaseWhen
  1259. */
  1260. static CaseWhen *
  1261. _copyCaseWhen(const CaseWhen *from)
  1262. {
  1263. CaseWhen *newnode = makeNode(CaseWhen);
  1264. COPY_NODE_FIELD(expr);
  1265. COPY_NODE_FIELD(result);
  1266. COPY_LOCATION_FIELD(location);
  1267. return newnode;
  1268. }
  1269. /*
  1270. * _copyCaseTestExpr
  1271. */
  1272. static CaseTestExpr *
  1273. _copyCaseTestExpr(const CaseTestExpr *from)
  1274. {
  1275. CaseTestExpr *newnode = makeNode(CaseTestExpr);
  1276. COPY_SCALAR_FIELD(typeId);
  1277. COPY_SCALAR_FIELD(typeMod);
  1278. COPY_SCALAR_FIELD(collation);
  1279. return newnode;
  1280. }
  1281. /*
  1282. * _copyArrayExpr
  1283. */
  1284. static ArrayExpr *
  1285. _copyArrayExpr(const ArrayExpr *from)
  1286. {
  1287. ArrayExpr *newnode = makeNode(ArrayExpr);
  1288. COPY_SCALAR_FIELD(array_typeid);
  1289. COPY_SCALAR_FIELD(array_collid);
  1290. COPY_SCALAR_FIELD(element_typeid);
  1291. COPY_NODE_FIELD(elements);
  1292. COPY_SCALAR_FIELD(multidims);
  1293. COPY_LOCATION_FIELD(location);
  1294. return newnode;
  1295. }
  1296. /*
  1297. * _copyRowExpr
  1298. */
  1299. static RowExpr *
  1300. _copyRowExpr(const RowExpr *from)
  1301. {
  1302. RowExpr *newnode = makeNode(RowExpr);
  1303. COPY_NODE_FIELD(args);
  1304. COPY_SCALAR_FIELD(row_typeid);
  1305. COPY_SCALAR_FIELD(row_format);
  1306. COPY_NODE_FIELD(colnames);
  1307. COPY_LOCATION_FIELD(location);
  1308. return newnode;
  1309. }
  1310. /*
  1311. * _copyRowCompareExpr
  1312. */
  1313. static RowCompareExpr *
  1314. _copyRowCompareExpr(const RowCompareExpr *from)
  1315. {
  1316. RowCompareExpr *newnode = makeNode(RowCompareExpr);
  1317. COPY_SCALAR_FIELD(rctype);
  1318. COPY_NODE_FIELD(opnos);
  1319. COPY_NODE_FIELD(opfamilies);
  1320. COPY_NODE_FIELD(inputcollids);
  1321. COPY_NODE_FIELD(largs);
  1322. COPY_NODE_FIELD(rargs);
  1323. return newnode;
  1324. }
  1325. /*
  1326. * _copyCoalesceExpr
  1327. */
  1328. static CoalesceExpr *
  1329. _copyCoalesceExpr(const CoalesceExpr *from)
  1330. {
  1331. CoalesceExpr *newnode = makeNode(CoalesceExpr);
  1332. COPY_SCALAR_FIELD(coalescetype);
  1333. COPY_SCALAR_FIELD(coalescecollid);
  1334. COPY_NODE_FIELD(args);
  1335. COPY_LOCATION_FIELD(location);
  1336. return newnode;
  1337. }
  1338. /*
  1339. * _copyMinMaxExpr
  1340. */
  1341. static MinMaxExpr *
  1342. _copyMinMaxExpr(const MinMaxExpr *from)
  1343. {
  1344. MinMaxExpr *newnode = makeNode(MinMaxExpr);
  1345. COPY_SCALAR_FIELD(minmaxtype);
  1346. COPY_SCALAR_FIELD(minmaxcollid);
  1347. COPY_SCALAR_FIELD(inputcollid);
  1348. COPY_SCALAR_FIELD(op);
  1349. COPY_NODE_FIELD(args);
  1350. COPY_LOCATION_FIELD(location);
  1351. return newnode;
  1352. }
  1353. /*
  1354. * _copyXmlExpr
  1355. */
  1356. static XmlExpr *
  1357. _copyXmlExpr(const XmlExpr *from)
  1358. {
  1359. XmlExpr *newnode = makeNode(XmlExpr);
  1360. COPY_SCALAR_FIELD(op);
  1361. COPY_STRING_FIELD(name);
  1362. COPY_NODE_FIELD(named_args);
  1363. COPY_NODE_FIELD(arg_names);
  1364. COPY_NODE_FIELD(args);
  1365. COPY_SCALAR_FIELD(xmloption);
  1366. COPY_SCALAR_FIELD(type);
  1367. COPY_SCALAR_FIELD(typmod);
  1368. COPY_LOCATION_FIELD(location);
  1369. return newnode;
  1370. }
  1371. /*
  1372. * _copyNullTest
  1373. */
  1374. static NullTest *
  1375. _copyNullTest(const NullTest *from)
  1376. {
  1377. NullTest *newnode = makeNode(NullTest);
  1378. COPY_NODE_FIELD(arg);
  1379. COPY_SCALAR_FIELD(nulltesttype);
  1380. COPY_SCALAR_FIELD(argisrow);
  1381. return newnode;
  1382. }
  1383. /*
  1384. * _copyBooleanTest
  1385. */
  1386. static BooleanTest *
  1387. _copyBooleanTest(const BooleanTest *from)
  1388. {
  1389. BooleanTest *newnode = makeNode(BooleanTest);
  1390. COPY_NODE_FIELD(arg);
  1391. COPY_SCALAR_FIELD(booltesttype);
  1392. return newnode;
  1393. }
  1394. /*
  1395. * _copyCoerceToDomain
  1396. */
  1397. static CoerceToDomain *
  1398. _copyCoerceToDomain(const CoerceToDomain *from)
  1399. {
  1400. CoerceToDomain *newnode = makeNode(CoerceToDomain);
  1401. COPY_NODE_FIELD(arg);
  1402. COPY_SCALAR_FIELD(resulttype);
  1403. COPY_SCALAR_FIELD(resulttypmod);
  1404. COPY_SCALAR_FIELD(resultcollid);
  1405. COPY_SCALAR_FIELD(coercionformat);
  1406. COPY_LOCATION_FIELD(location);
  1407. return newnode;
  1408. }
  1409. /*
  1410. * _copyCoerceToDomainValue
  1411. */
  1412. static CoerceToDomainValue *
  1413. _copyCoerceToDomainValue(const CoerceToDomainValue *from)
  1414. {
  1415. CoerceToDomainValue *newnode = makeNode(CoerceToDomainValue);
  1416. COPY_SCALAR_FIELD(typeId);
  1417. COPY_SCALAR_FIELD(typeMod);
  1418. COPY_SCALAR_FIELD(collation);
  1419. COPY_LOCATION_FIELD(location);
  1420. return newnode;
  1421. }
  1422. /*
  1423. * _copySetToDefault
  1424. */
  1425. static SetToDefault *
  1426. _copySetToDefault(const SetToDefault *from)
  1427. {
  1428. SetToDefault *newnode = makeNode(SetToDefault);
  1429. COPY_SCALAR_FIELD(typeId);
  1430. COPY_SCALAR_FIELD(typeMod);
  1431. COPY_SCALAR_FIELD(collation);
  1432. COPY_LOCATION_FIELD(location);
  1433. return newnode;
  1434. }
  1435. /*
  1436. * _copyCurrentOfExpr
  1437. */
  1438. static CurrentOfExpr *
  1439. _copyCurrentOfExpr(const CurrentOfExpr *from)
  1440. {
  1441. CurrentOfExpr *newnode = makeNode(CurrentOfExpr);
  1442. COPY_SCALAR_FIELD(cvarno);
  1443. COPY_STRING_FIELD(cursor_name);
  1444. COPY_SCALAR_FIELD(cursor_param);
  1445. return newnode;
  1446. }
  1447. /*
  1448. * _copyTargetEntry
  1449. */
  1450. static TargetEntry *
  1451. _copyTargetEntry(const TargetEntry *from)
  1452. {
  1453. TargetEntry *newnode = makeNode(TargetEntry);
  1454. COPY_NODE_FIELD(expr);
  1455. COPY_SCALAR_FIELD(resno);
  1456. COPY_STRING_FIELD(resname);
  1457. COPY_SCALAR_FIELD(ressortgroupref);
  1458. COPY_SCALAR_FIELD(resorigtbl);
  1459. COPY_SCALAR_FIELD(resorigcol);
  1460. COPY_SCALAR_FIELD(resjunk);
  1461. return newnode;
  1462. }
  1463. /*
  1464. * _copyRangeTblRef
  1465. */
  1466. static RangeTblRef *
  1467. _copyRangeTblRef(const RangeTblRef *from)
  1468. {
  1469. RangeTblRef *newnode = makeNode(RangeTblRef);
  1470. COPY_SCALAR_FIELD(rtindex);
  1471. return newnode;
  1472. }
  1473. /*
  1474. * _copyJoinExpr
  1475. */
  1476. static JoinExpr *
  1477. _copyJoinExpr(const JoinExpr *from)
  1478. {
  1479. JoinExpr *newnode = makeNode(JoinExpr);
  1480. COPY_SCALAR_FIELD(jointype);
  1481. COPY_SCALAR_FIELD(isNatural);
  1482. COPY_NODE_FIELD(larg);
  1483. COPY_NODE_FIELD(rarg);
  1484. COPY_NODE_FIELD(usingClause);
  1485. COPY_NODE_FIELD(quals);
  1486. COPY_NODE_FIELD(alias);
  1487. COPY_SCALAR_FIELD(rtindex);
  1488. return newnode;
  1489. }
  1490. /*
  1491. * _copyFromExpr
  1492. */
  1493. static FromExpr *
  1494. _copyFromExpr(const FromExpr *from)
  1495. {
  1496. FromExpr *newnode = makeNode(FromExpr);
  1497. COPY_NODE_FIELD(fromlist);
  1498. COPY_NODE_FIELD(quals);
  1499. return newnode;
  1500. }
  1501. /* ****************************************************************
  1502. * relation.h copy functions
  1503. *
  1504. * We don't support copying RelOptInfo, IndexOptInfo, or Path nodes.
  1505. * There are some subsidiary structs that are useful to copy, though.
  1506. * ****************************************************************
  1507. */
  1508. /*
  1509. * _copyPathKey
  1510. */
  1511. static PathKey *
  1512. _copyPathKey(const PathKey *from)
  1513. {
  1514. PathKey *newnode = makeNode(PathKey);
  1515. /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
  1516. COPY_SCALAR_FIELD(pk_eclass);
  1517. COPY_SCALAR_FIELD(pk_opfamily);
  1518. COPY_SCALAR_FIELD(pk_strategy);
  1519. COPY_SCALAR_FIELD(pk_nulls_first);
  1520. return newnode;
  1521. }
  1522. /*
  1523. * _copyRestrictInfo
  1524. */
  1525. static RestrictInfo *
  1526. _copyRestrictInfo(const RestrictInfo *from)
  1527. {
  1528. RestrictInfo *newnode = makeNode(RestrictInfo);
  1529. COPY_NODE_FIELD(clause);
  1530. COPY_SCALAR_FIELD(is_pushed_down);
  1531. COPY_SCALAR_FIELD(outerjoin_delayed);
  1532. COPY_SCALAR_FIELD(can_join);
  1533. COPY_SCALAR_FIELD(pseudoconstant);
  1534. COPY_BITMAPSET_FIELD(clause_relids);
  1535. COPY_BITMAPSET_FIELD(required_relids);
  1536. COPY_BITMAPSET_FIELD(outer_relids);
  1537. COPY_BITMAPSET_FIELD(nullable_relids);
  1538. COPY_BITMAPSET_FIELD(left_relids);
  1539. COPY_BITMAPSET_FIELD(right_relids);
  1540. COPY_NODE_FIELD(orclause);
  1541. /* EquivalenceClasses are never copied, so shallow-copy the pointers */
  1542. COPY_SCALAR_FIELD(parent_ec);
  1543. COPY_SCALAR_FIELD(eval_cost);
  1544. COPY_SCALAR_FIELD(norm_selec);
  1545. COPY_SCALAR_FIELD(outer_selec);
  1546. COPY_NODE_FIELD(mergeopfamilies);
  1547. /* EquivalenceClasses are never copied, so shallow-copy the pointers */
  1548. COPY_SCALAR_FIELD(left_ec);
  1549. COPY_SCALAR_FIELD(right_ec);
  1550. COPY_SCALAR_FIELD(left_em);
  1551. COPY_SCALAR_FIELD(right_em);
  1552. /* MergeScanSelCache isn't a Node, so hard to copy; just reset cache */
  1553. newnode->scansel_cache = NIL;
  1554. COPY_SCALAR_FIELD(outer_is_left);
  1555. COPY_SCALAR_FIELD(hashjoinoperator);
  1556. COPY_SCALAR_FIELD(left_bucketsize);
  1557. COPY_SCALAR_FIELD(right_bucketsize);
  1558. return newnode;
  1559. }
  1560. /*
  1561. * _copyPlaceHolderVar
  1562. */
  1563. static PlaceHolderVar *
  1564. _copyPlaceHolderVar(const PlaceHolderVar *from)
  1565. {
  1566. PlaceHolderVar *newnode = makeNode(PlaceHolderVar);
  1567. COPY_NODE_FIELD(phexpr);
  1568. COPY_BITMAPSET_FIELD(phrels);
  1569. COPY_SCALAR_FIELD(phid);
  1570. COPY_SCALAR_FIELD(phlevelsup);
  1571. return newnode;
  1572. }
  1573. /*
  1574. * _copySpecialJoinInfo
  1575. */
  1576. static SpecialJoinInfo *
  1577. _copySpecialJoinInfo(const SpecialJoinInfo *from)
  1578. {
  1579. SpecialJoinInfo *newnode = makeNode(SpecialJoinInfo);
  1580. COPY_BITMAPSET_FIELD(min_lefthand);
  1581. COPY_BITMAPSET_FIELD(min_righthand);
  1582. COPY_BITMAPSET_FIELD(syn_lefthand);
  1583. COPY_BITMAPSET_FIELD(syn_righthand);
  1584. COPY_SCALAR_FIELD(jointype);
  1585. COPY_SCALAR_FIELD(lhs_strict);
  1586. COPY_SCALAR_FIELD(delay_upper_joins);
  1587. COPY_NODE_FIELD(join_quals);
  1588. return newnode;
  1589. }
  1590. /*
  1591. * _copyLateralJoinInfo
  1592. */
  1593. static LateralJoinInfo *
  1594. _copyLateralJoinInfo(const LateralJoinInfo *from)
  1595. {
  1596. LateralJoinInfo *newnode = makeNode(LateralJoinInfo);
  1597. COPY_BITMAPSET_FIELD(lateral_lhs);
  1598. COPY_BITMAPSET_FIELD(lateral_rhs);
  1599. return newnode;
  1600. }
  1601. /*
  1602. * _copyAppendRelInfo
  1603. */
  1604. static AppendRelInfo *
  1605. _copyAppendRelInfo(const AppendRelInfo *from)
  1606. {
  1607. AppendRelInfo *newnode = makeNode(AppendRelInfo);
  1608. COPY_SCALAR_FIELD(parent_relid);
  1609. COPY_SCALAR_FIELD(child_relid);
  1610. COPY_SCALAR_FIELD(parent_reltype);
  1611. COPY_SCALAR_FIELD(child_reltype);
  1612. COPY_NODE_FIELD(translated_vars);
  1613. COPY_SCALAR_FIELD(parent_reloid);
  1614. return newnode;
  1615. }
  1616. /*
  1617. * _copyPlaceHolderInfo
  1618. */
  1619. static PlaceHolderInfo *
  1620. _copyPlaceHolderInfo(const PlaceHolderInfo *from)
  1621. {
  1622. PlaceHolderInfo *newnode = makeNode(PlaceHolderInfo);
  1623. COPY_SCALAR_FIELD(phid);
  1624. COPY_NODE_FIELD(ph_var);
  1625. COPY_BITMAPSET_FIELD(ph_eval_at);
  1626. COPY_BITMAPSET_FIELD(ph_lateral);
  1627. COPY_BITMAPSET_FIELD(ph_needed);
  1628. COPY_SCALAR_FIELD(ph_width);
  1629. return newnode;
  1630. }
  1631. /* ****************************************************************
  1632. * parsenodes.h copy functions
  1633. * ****************************************************************
  1634. */
  1635. static RangeTblEntry *
  1636. _copyRangeTblEntry(const RangeTblEntry *from)
  1637. {
  1638. RangeTblEntry *newnode = makeNode(RangeTblEntry);
  1639. COPY_SCALAR_FIELD(rtekind);
  1640. COPY_SCALAR_FIELD(relid);
  1641. COPY_SCALAR_FIELD(relkind);
  1642. COPY_NODE_FIELD(subquery);
  1643. COPY_SCALAR_FIELD(security_barrier);
  1644. COPY_SCALAR_FIELD(jointype);
  1645. COPY_NODE_FIELD(joinaliasvars);
  1646. COPY_NODE_FIELD(functions);
  1647. COPY_SCALAR_FIELD(funcordinality);
  1648. COPY_NODE_FIELD(values_lists);
  1649. COPY_NODE_FIELD(values_collations);
  1650. COPY_STRING_FIELD(ctename);
  1651. COPY_SCALAR_FIELD(ctelevelsup);
  1652. COPY_SCALAR_FIELD(self_reference);
  1653. COPY_NODE_FIELD(ctecoltypes);
  1654. COPY_NODE_FIELD(ctecoltypmods);
  1655. COPY_NODE_FIELD(ctecolcollations);
  1656. COPY_NODE_FIELD(alias);
  1657. COPY_NODE_FIELD(eref);
  1658. COPY_SCALAR_FIELD(lateral);
  1659. COPY_SCALAR_FIELD(inh);
  1660. COPY_SCALAR_FIELD(inFromCl);
  1661. COPY_SCALAR_FIELD(requiredPerms);
  1662. COPY_SCALAR_FIELD(checkAsUser);
  1663. COPY_BITMAPSET_FIELD(selectedCols);
  1664. COPY_BITMAPSET_FIELD(modifiedCols);
  1665. COPY_NODE_FIELD(securityQuals);
  1666. return newnode;
  1667. }
  1668. static RangeTblFunction *
  1669. _copyRangeTblFunction(const RangeTblFunction *from)
  1670. {
  1671. RangeTblFunction *newnode = makeNode(RangeTblFunction);
  1672. COPY_NODE_FIELD(funcexpr);
  1673. COPY_SCALAR_FIELD(funccolcount);
  1674. COPY_NODE_FIELD(funccolnames);
  1675. COPY_NODE_FIELD(funccoltypes);
  1676. COPY_NODE_FIELD(funccoltypmods);
  1677. COPY_NODE_FIELD(funccolcollations);
  1678. COPY_BITMAPSET_FIELD(funcparams);
  1679. return newnode;
  1680. }
  1681. static WithCheckOption *
  1682. _copyWithCheckOption(const WithCheckOption *from)
  1683. {
  1684. WithCheckOption *newnode = makeNode(WithCheckOption);
  1685. COPY_STRING_FIELD(viewname);
  1686. COPY_NODE_FIELD(qual);
  1687. COPY_SCALAR_FIELD(cascaded);
  1688. return newnode;
  1689. }
  1690. static SortGroupClause *
  1691. _copySortGroupClause(const SortGroupClause *from)
  1692. {
  1693. SortGroupClause *newnode = makeNode(SortGroupClause);
  1694. COPY_SCALAR_FIELD(tleSortGroupRef);
  1695. COPY_SCALAR_FIELD(eqop);
  1696. COPY_SCALAR_FIELD(sortop);
  1697. COPY_SCALAR_FIELD(nulls_first);
  1698. COPY_SCALAR_FIELD(hashable);
  1699. return newnode;
  1700. }
  1701. static WindowClause *
  1702. _copyWindowClause(const WindowClause *from)
  1703. {
  1704. WindowClause *newnode = makeNode(WindowClause);
  1705. COPY_STRING_FIELD(name);
  1706. COPY_STRING_FIELD(refname);
  1707. COPY_NODE_FIELD(partitionClause);
  1708. COPY_NODE_FIELD(orderClause);
  1709. COPY_SCALAR_FIELD(frameOptions);
  1710. COPY_NODE_FIELD(startOffset);
  1711. COPY_NODE_FIELD(endOffset);
  1712. COPY_SCALAR_FIELD(winref);
  1713. COPY_SCALAR_FIELD(copiedOrder);
  1714. return newnode;
  1715. }
  1716. static RowMarkClause *
  1717. _copyRowMarkClause(const RowMarkClause *from)
  1718. {
  1719. RowMarkClause *newnode = makeNode(RowMarkClause);
  1720. COPY_SCALAR_FIELD(rti);
  1721. COPY_SCALAR_FIELD(strength);
  1722. COPY_SCALAR_FIELD(noWait);
  1723. COPY_SCALAR_FIELD(pushedDown);
  1724. return newnode;
  1725. }
  1726. static WithClause *
  1727. _copyWithClause(const WithClause *from)
  1728. {
  1729. WithClause *newnode = makeNode(WithClause);
  1730. COPY_NODE_FIELD(ctes);
  1731. COPY_SCALAR_FIELD(recursive);
  1732. COPY_LOCATION_FIELD(location);
  1733. return newnode;
  1734. }
  1735. static CommonTableExpr *
  1736. _copyCommonTableExpr(const CommonTableExpr *from)
  1737. {
  1738. CommonTableExpr *newnode = makeNode(CommonTableExpr);
  1739. COPY_STRING_FIELD(ctename);
  1740. COPY_NODE_FIELD(aliascolnames);
  1741. COPY_NODE_FIELD(ctequery);
  1742. COPY_LOCATION_FIELD(location);
  1743. COPY_SCALAR_FIELD(cterecursive);
  1744. COPY_SCALAR_FIELD(cterefcount);
  1745. COPY_NODE_FIELD(ctecolnames);
  1746. COPY_NODE_FIELD(ctecoltypes);
  1747. COPY_NODE_FIELD(ctecoltypmods);
  1748. COPY_NODE_FIELD(ctecolcollations);
  1749. return newnode;
  1750. }
  1751. static A_Expr *
  1752. _copyAExpr(const A_Expr *from)
  1753. {
  1754. A_Expr *newnode = makeNode(A_Expr);
  1755. COPY_SCALAR_FIELD(kind);
  1756. COPY_NODE_FIELD(name);
  1757. COPY_NODE_FIELD(lexpr);
  1758. COPY_NODE_FIELD(rexpr);
  1759. COPY_LOCATION_FIELD(location);
  1760. return newnode;
  1761. }
  1762. static ColumnRef *
  1763. _copyColumnRef(const ColumnRef *from)
  1764. {
  1765. ColumnRef *newnode = makeNode(ColumnRef);
  1766. COPY_NODE_FIELD(fields);
  1767. COPY_LOCATION_FIELD(location);
  1768. return newnode;
  1769. }
  1770. static ParamRef *
  1771. _copyParamRef(const ParamRef *from)
  1772. {
  1773. ParamRef *newnode = makeNode(ParamRef);
  1774. COPY_SCALAR_FIELD(number);
  1775. COPY_LOCATION_FIELD(location);
  1776. return newnode;
  1777. }
  1778. static A_Const *
  1779. _copyAConst(const A_Const *from)
  1780. {
  1781. A_Const *newnode = makeNode(A_Const);
  1782. /* This part must duplicate _copyValue */
  1783. COPY_SCALAR_FIELD(val.type);
  1784. switch (from->val.type)
  1785. {
  1786. case T_Integer:
  1787. COPY_SCALAR_FIELD(val.val.ival);
  1788. break;
  1789. case T_Float:
  1790. case T_String:
  1791. case T_BitString:
  1792. COPY_STRING_FIELD(val.val.str);
  1793. break;
  1794. case T_Null:
  1795. /* nothing to do */
  1796. break;
  1797. default:
  1798. elog(ERROR, "unrecognized node type: %d",
  1799. (int) from->val.type);
  1800. break;
  1801. }
  1802. COPY_LOCATION_FIELD(location);
  1803. return newnode;
  1804. }
  1805. static FuncCall *
  1806. _copyFuncCall(const FuncCall *from)
  1807. {
  1808. FuncCall *newnode = makeNode(FuncCall);
  1809. COPY_NODE_FIELD(funcname);
  1810. COPY_NODE_FIELD(args);
  1811. COPY_NODE_FIELD(agg_order);
  1812. COPY_NODE_FIELD(agg_filter);
  1813. COPY_SCALAR_FIELD(agg_within_group);
  1814. COPY_SCALAR_FIELD(agg_star);
  1815. COPY_SCALAR_FIELD(agg_distinct);
  1816. COPY_SCALAR_FIELD(func_variadic);
  1817. COPY_NODE_FIELD(over);
  1818. COPY_LOCATION_FIELD(location);
  1819. return newnode;
  1820. }
  1821. static A_Star *
  1822. _copyAStar(const A_Star *from)
  1823. {
  1824. A_Star *newnode = makeNode(A_Star);
  1825. return newnode;
  1826. }
  1827. static A_Indices *
  1828. _copyAIndices(const A_Indices *from)
  1829. {
  1830. A_Indices *newnode = makeNode(A_Indices);
  1831. COPY_NODE_FIELD(lidx);
  1832. COPY_NODE_FIELD(uidx);
  1833. return newnode;
  1834. }
  1835. static A_Indirection *
  1836. _copyA_Indirection(const A_Indirection *from)
  1837. {
  1838. A_Indirection *newnode = makeNode(A_Indirection);
  1839. COPY_NODE_FIELD(arg);
  1840. COPY_NODE_FIELD(indirection);
  1841. return newnode;
  1842. }
  1843. static A_ArrayExpr *
  1844. _copyA_ArrayExpr(const A_ArrayExpr *from)
  1845. {
  1846. A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
  1847. COPY_NODE_FIELD(elements);
  1848. COPY_LOCATION_FIELD(location);
  1849. return newnode;
  1850. }
  1851. static ResTarget *
  1852. _copyResTarget(const ResTarget *from)
  1853. {
  1854. ResTarget *newnode = makeNode(ResTarget);
  1855. COPY_STRING_FIELD(name);
  1856. COPY_NODE_FIELD(indirection);
  1857. COPY_NODE_FIELD(val);
  1858. COPY_LOCATION_FIELD(location);
  1859. return newnode;
  1860. }
  1861. static TypeName *
  1862. _copyTypeName(const TypeName *from)
  1863. {
  1864. TypeName *newnode = makeNode(TypeName);
  1865. COPY_NODE_FIELD(names);
  1866. COPY_SCALAR_FIELD(typeOid);
  1867. COPY_SCALAR_FIELD(setof);
  1868. COPY_SCALAR_FIELD(pct_type);
  1869. COPY_NODE_FIELD(typmods);
  1870. COPY_SCALAR_FIELD(typemod);
  1871. COPY_NODE_FIELD(arrayBounds);
  1872. COPY_LOCATION_FIELD(location);
  1873. return newnode;
  1874. }
  1875. static SortBy *
  1876. _copySortBy(const SortBy *from)
  1877. {
  1878. SortBy *newnode = makeNode(SortBy);
  1879. COPY_NODE_FIELD(node);
  1880. COPY_SCALAR_FIELD(sortby_dir);
  1881. COPY_SCALAR_FIELD(sortby_nulls);
  1882. COPY_NODE_FIELD(useOp);
  1883. COPY_LOCATION_FIELD(location);
  1884. return newnode;
  1885. }
  1886. static WindowDef *
  1887. _copyWindowDef(const WindowDef *from)
  1888. {
  1889. WindowDef *newnode = makeNode(WindowDef);
  1890. COPY_STRING_FIELD(name);
  1891. COPY_STRING_FIELD(refname);
  1892. COPY_NODE_FIELD(partitionClause);
  1893. COPY_NODE_FIELD(orderClause);
  1894. COPY_SCALAR_FIELD(frameOptions);
  1895. COPY_NODE_FIELD(startOffset);
  1896. COPY_NODE_FIELD(endOffset);
  1897. COPY_LOCATION_FIELD(location);
  1898. return newnode;
  1899. }
  1900. static RangeSubselect *
  1901. _copyRangeSubselect(const RangeSubselect *from)
  1902. {
  1903. RangeSubselect *newnode = makeNode(RangeSubselect);
  1904. COPY_SCALAR_FIELD(lateral);
  1905. COPY_NODE_FIELD(subquery);
  1906. COPY_NODE_FIELD(alias);
  1907. return newnode;
  1908. }
  1909. static RangeFunction *
  1910. _copyRangeFunction(const RangeFunction *from)
  1911. {
  1912. RangeFunction *newnode = makeNode(RangeFunction);
  1913. COPY_SCALAR_FIELD(lateral);
  1914. COPY_SCALAR_FIELD(ordinality);
  1915. COPY_SCALAR_FIELD(is_rowsfrom);
  1916. COPY_NODE_FIELD(functions);
  1917. COPY_NODE_FIELD(alias);
  1918. COPY_NODE_FIELD(coldeflist);
  1919. return newnode;
  1920. }
  1921. static TypeCast *
  1922. _copyTypeCast(const TypeCast *from)
  1923. {
  1924. TypeCast *newnode = makeNode(TypeCast);
  1925. COPY_NODE_FIELD(arg);
  1926. COPY_NODE_FIELD(typeName);
  1927. COPY_LOCATION_FIELD(location);
  1928. return newnode;
  1929. }
  1930. static CollateClause *
  1931. _copyCollateClause(const CollateClause *from)
  1932. {
  1933. CollateClause *newnode = makeNode(CollateClause);
  1934. COPY_NODE_FIELD(arg);
  1935. COPY_NODE_FIELD(collname);
  1936. COPY_LOCATION_FIELD(location);
  1937. return newnode;
  1938. }
  1939. static IndexElem *
  1940. _copyIndexElem(const IndexElem *from)
  1941. {
  1942. IndexElem *newnode = makeNode(IndexElem);
  1943. COPY_STRING_FIELD(name);
  1944. COPY_NODE_FIELD(expr);
  1945. COPY_STRING_FIELD(indexcolname);
  1946. COPY_NODE_FIELD(collation);
  1947. COPY_NODE_FIELD(opclass);
  1948. COPY_SCALAR_FIELD(ordering);
  1949. COPY_SCALAR_FIELD(nulls_ordering);
  1950. return newnode;
  1951. }
  1952. static ColumnDef *
  1953. _copyColumnDef(const ColumnDef *from)
  1954. {
  1955. ColumnDef *newnode = makeNode(ColumnDef);
  1956. COPY_STRING_FIELD(colname);
  1957. COPY_NODE_FIELD(typeName);
  1958. COPY_SCALAR_FIELD(inhcount);
  1959. COPY_SCALAR_FIELD(is_local);
  1960. COPY_SCALAR_FIELD(is_not_null);
  1961. COPY_SCALAR_FIELD(is_from_type);
  1962. COPY_SCALAR_FIELD(storage);
  1963. COPY_NODE_FIELD(raw_default);
  1964. COPY_NODE_FIELD(cooked_default);
  1965. COPY_NODE_FIELD(collClause);
  1966. COPY_SCALAR_FIELD(collOid);
  1967. COPY_NODE_FIELD(constraints);
  1968. COPY_NODE_FIELD(fdwoptions);
  1969. COPY_LOCATION_FIELD(location);
  1970. return newnode;
  1971. }
  1972. static Constraint *
  1973. _copyConstraint(const Constraint *from)
  1974. {
  1975. Constraint *newnode = makeNode(Constraint);
  1976. COPY_SCALAR_FIELD(contype);
  1977. COPY_STRING_FIELD(conname);
  1978. COPY_SCALAR_FIELD(deferrable);
  1979. COPY_SCALAR_FIELD(initdeferred);
  1980. COPY_LOCATION_FIELD(location);
  1981. COPY_SCALAR_FIELD(is_no_inherit);
  1982. COPY_NODE_FIELD(raw_expr);
  1983. COPY_STRING_FIELD(cooked_expr);
  1984. COPY_NODE_FIELD(keys);
  1985. COPY_NODE_FIELD(exclusions);
  1986. COPY_NODE_FIELD(options);
  1987. COPY_STRING_FIELD(indexname);
  1988. COPY_STRING_FIELD(indexspace);
  1989. COPY_STRING_FIELD(access_method);
  1990. COPY_NODE_FIELD(where_clause);
  1991. COPY_NODE_FIELD(pktable);
  1992. COPY_NODE_FIELD(fk_attrs);
  1993. COPY_NODE_FIELD(pk_attrs);
  1994. COPY_SCALAR_FIELD(fk_matchtype);
  1995. COPY_SCALAR_FIELD(fk_upd_action);
  1996. COPY_SCALAR_FIELD(fk_del_action);
  1997. COPY_NODE_FIELD(old_conpfeqop);
  1998. COPY_SCALAR_FIELD(old_pktable_oid);
  1999. COPY_SCALAR_FIELD(skip_validation);
  2000. COPY_SCALAR_FIELD(initially_valid);
  2001. return newnode;
  2002. }
  2003. static DefElem *
  2004. _copyDefElem(const DefElem *from)
  2005. {
  2006. DefElem *newnode = makeNode(DefElem);
  2007. COPY_STRING_FIELD(defnamespace);
  2008. COPY_STRING_FIELD(defname);
  2009. COPY_NODE_FIELD(arg);
  2010. COPY_SCALAR_FIELD(defaction);
  2011. return newnode;
  2012. }
  2013. static LockingClause *
  2014. _copyLockingClause(const LockingClause *from)
  2015. {
  2016. LockingClause *newnode = makeNode(LockingClause);
  2017. COPY_NODE_FIELD(lockedRels);
  2018. COPY_SCALAR_FIELD(strength);
  2019. COPY_SCALAR_FIELD(noWait);
  2020. return newnode;
  2021. }
  2022. static XmlSerialize *
  2023. _copyXmlSerialize(const XmlSerialize *from)
  2024. {
  2025. XmlSerialize *newnode = makeNode(XmlSerialize);
  2026. COPY_SCALAR_FIELD(xmloption);
  2027. COPY_NODE_FIELD(expr);
  2028. COPY_NODE_FIELD(typeName);
  2029. COPY_LOCATION_FIELD(location);
  2030. return newnode;
  2031. }
  2032. static Query *
  2033. _copyQuery(const Query *from)
  2034. {
  2035. Query *newnode = makeNode(Query);
  2036. COPY_SCALAR_FIELD(commandType);
  2037. COPY_SCALAR_FIELD(querySource);
  2038. COPY_SCALAR_FIELD(queryId);
  2039. COPY_SCALAR_FIELD(canSetTag);
  2040. COPY_NODE_FIELD(utilityStmt);
  2041. COPY_SCALAR_FIELD(resultRelation);
  2042. COPY_SCALAR_FIELD(hasAggs);
  2043. COPY_SCALAR_FIELD(hasWindowFuncs);
  2044. COPY_SCALAR_FIELD(hasSubLinks);
  2045. COPY_SCALAR_FIELD(hasDistinctOn);
  2046. COPY_SCALAR_FIELD(hasRecursive);
  2047. COPY_SCALAR_FIELD(hasModifyingCTE);
  2048. COPY_SCALAR_FIELD(hasForUpdate);
  2049. COPY_NODE_FIELD(cteList);
  2050. COPY_NODE_FIELD(rtable);
  2051. COPY_NODE_FIELD(jointree);
  2052. COPY_NODE_FIELD(targetList);
  2053. COPY_NODE_FIELD(withCheckOptions);
  2054. COPY_NODE_FIELD(returningList);
  2055. COPY_NODE_FIELD(groupClause);
  2056. COPY_NODE_FIELD(havingQual);
  2057. COPY_NODE_FIELD(windowClause);
  2058. COPY_NODE_FIELD(distinctClause);
  2059. COPY_NODE_FIELD(sortClause);
  2060. COPY_NODE_FIELD(limitOffset);
  2061. COPY_NODE_FIELD(limitCount);
  2062. COPY_NODE_FIELD(rowMarks);
  2063. COPY_NODE_FIELD(setOperations);
  2064. COPY_NODE_FIELD(constraintDeps);
  2065. return newnode;
  2066. }
  2067. static InsertStmt *
  2068. _copyInsertStmt(const InsertStmt *from)
  2069. {
  2070. InsertStmt *newnode = makeNode(InsertStmt);
  2071. COPY_NODE_FIELD(relation);
  2072. COPY_NODE_FIELD(cols);
  2073. COPY_NODE_FIELD(selectStmt);
  2074. COPY_NODE_FIELD(returningList);
  2075. COPY_NODE_FIELD(withClause);
  2076. return newnode;
  2077. }
  2078. static DeleteStmt *
  2079. _copyDeleteStmt(const DeleteStmt *from)
  2080. {
  2081. DeleteStmt *newnode = makeNode(DeleteStmt);
  2082. COPY_NODE_FIELD(relation);
  2083. COPY_NODE_FIELD(usingClause);
  2084. COPY_NODE_FIELD(whereClause);
  2085. COPY_NODE_FIELD(returningList);
  2086. COPY_NODE_FIELD(withClause);
  2087. return newnode;
  2088. }
  2089. static UpdateStmt *
  2090. _copyUpdateStmt(const UpdateStmt *from)
  2091. {
  2092. UpdateStmt *newnode = makeNode(UpdateStmt);
  2093. COPY_NODE_FIELD(relation);
  2094. COPY_NODE_FIELD(targetList);
  2095. COPY_NODE_FIELD(whereClause);
  2096. COPY_NODE_FIELD(fromClause);
  2097. COPY_NODE_FIELD(returningList);
  2098. COPY_NODE_FIELD(withClause);
  2099. return newnode;
  2100. }
  2101. static SelectStmt *
  2102. _copySelectStmt(const SelectStmt *from)
  2103. {
  2104. SelectStmt *newnode = makeNode(SelectStmt);
  2105. COPY_NODE_FIELD(distinctClause);
  2106. COPY_NODE_FIELD(intoClause);
  2107. COPY_NODE_FIELD(targetList);
  2108. COPY_NODE_FIELD(fromClause);
  2109. COPY_NODE_FIELD(whereClause);
  2110. COPY_NODE_FIELD(groupClause);
  2111. COPY_NODE_FIELD(havingClause);
  2112. COPY_NODE_FIELD(windowClause);
  2113. COPY_NODE_FIELD(valuesLists);
  2114. COPY_NODE_FIELD(sortClause);
  2115. COPY_NODE_FIELD(limitOffset);
  2116. COPY_NODE_FIELD(limitCount);
  2117. COPY_NODE_FIELD(lockingClause);
  2118. COPY_NODE_FIELD(withClause);
  2119. COPY_SCALAR_FIELD(op);
  2120. COPY_SCALAR_FIELD(all);
  2121. COPY_NODE_FIELD(larg);
  2122. COPY_NODE_FIELD(rarg);
  2123. return newnode;
  2124. }
  2125. static SetOperationStmt *
  2126. _copySetOperationStmt(const SetOperationStmt *from)
  2127. {
  2128. SetOperationStmt *newnode = makeNode(SetOperationStmt);
  2129. COPY_SCALAR_FIELD(op);
  2130. COPY_SCALAR_FIELD(all);
  2131. COPY_NODE_FIELD(larg);
  2132. COPY_NODE_FIELD(rarg);
  2133. COPY_NODE_FIELD(colTypes);
  2134. COPY_NODE_FIELD(colTypmods);
  2135. COPY_NODE_FIELD(colCollations);
  2136. COPY_NODE_FIELD(groupClauses);
  2137. return newnode;
  2138. }
  2139. static AlterTableStmt *
  2140. _copyAlterTableStmt(const AlterTableStmt *from)
  2141. {
  2142. AlterTableStmt *newnode = makeNode(AlterTableStmt);
  2143. COPY_NODE_FIELD(relation);
  2144. COPY_NODE_FIELD(cmds);
  2145. COPY_SCALAR_FIELD(relkind);
  2146. COPY_SCALAR_FIELD(missing_ok);
  2147. return newnode;
  2148. }
  2149. static AlterTableCmd *
  2150. _copyAlterTableCmd(const AlterTableCmd *from)
  2151. {
  2152. AlterTableCmd *newnode = makeNode(AlterTableCmd);
  2153. COPY_SCALAR_FIELD(subtype);
  2154. COPY_STRING_FIELD(name);
  2155. COPY_NODE_FIELD(def);
  2156. COPY_SCALAR_FIELD(behavior);
  2157. COPY_SCALAR_FIELD(missing_ok);
  2158. return newnode;
  2159. }
  2160. static AlterDomainStmt *
  2161. _copyAlterDomainStmt(const AlterDomainStmt *from)
  2162. {
  2163. AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
  2164. COPY_SCALAR_FIELD(subtype);
  2165. COPY_NODE_FIELD(typeName);
  2166. COPY_STRING_FIELD(name);
  2167. COPY_NODE_FIELD(def);
  2168. COPY_SCALAR_FIELD(behavior);
  2169. COPY_SCALAR_FIELD(missing_ok);
  2170. return newnode;
  2171. }
  2172. static GrantStmt *
  2173. _copyGrantStmt(const GrantStmt *from)
  2174. {
  2175. GrantStmt *newnode = makeNode(GrantStmt);
  2176. COPY_SCALAR_FIELD(is_grant);
  2177. COPY_SCALAR_FIELD(targtype);
  2178. COPY_SCALAR_FIELD(objtype);
  2179. COPY_NODE_FIELD(objects);
  2180. COPY_NODE_FIELD(privileges);
  2181. COPY_NODE_FIELD(grantees);
  2182. COPY_SCALAR_FIELD(grant_option);
  2183. COPY_SCALAR_FIELD(behavior);
  2184. return newnode;
  2185. }
  2186. static PrivGrantee *
  2187. _copyPrivGrantee(const PrivGrantee *from)
  2188. {
  2189. PrivGrantee *newnode = makeNode(PrivGrantee);
  2190. COPY_STRING_FIELD(rolname);
  2191. return newnode;
  2192. }
  2193. static FuncWithArgs *
  2194. _copyFuncWithArgs(const FuncWithArgs *from)
  2195. {
  2196. FuncWithArgs *newnode = makeNode(FuncWithArgs);
  2197. COPY_NODE_FIELD(funcname);
  2198. COPY_NODE_FIELD(funcargs);
  2199. return newnode;
  2200. }
  2201. static AccessPriv *
  2202. _copyAccessPriv(const AccessPriv *from)
  2203. {
  2204. AccessPriv *newnode = makeNode(AccessPriv);
  2205. COPY_STRING_FIELD(priv_name);
  2206. COPY_NODE_FIELD(cols);
  2207. return newnode;
  2208. }
  2209. static GrantRoleStmt *
  2210. _copyGrantRoleStmt(const GrantRoleStmt *from)
  2211. {
  2212. GrantRoleStmt *newnode = makeNode(GrantRoleStmt);
  2213. COPY_NODE_FIELD(granted_roles);
  2214. COPY_NODE_FIELD(grantee_roles);
  2215. COPY_SCALAR_FIELD(is_grant);
  2216. COPY_SCALAR_FIELD(admin_opt);
  2217. COPY_STRING_FIELD(grantor);
  2218. COPY_SCALAR_FIELD(behavior);
  2219. return newnode;
  2220. }
  2221. static AlterDefaultPrivilegesStmt *
  2222. _copyAlterDefaultPrivilegesStmt(const AlterDefaultPrivilegesStmt *from)
  2223. {
  2224. AlterDefaultPrivilegesStmt *newnode = makeNode(AlterDefaultPrivilegesStmt);
  2225. COPY_NODE_FIELD(options);
  2226. COPY_NODE_FIELD(action);
  2227. return newnode;
  2228. }
  2229. static DeclareCursorStmt *
  2230. _copyDeclareCursorStmt(const DeclareCursorStmt *from)
  2231. {
  2232. DeclareCursorStmt *newnode = makeNode(DeclareCursorStmt);
  2233. COPY_STRING_FIELD(portalname);
  2234. COPY_SCALAR_FIELD(options);
  2235. COPY_NODE_FIELD(query);
  2236. return newnode;
  2237. }
  2238. static ClosePortalStmt *
  2239. _copyClosePortalStmt(const ClosePortalStmt *from)
  2240. {
  2241. ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
  2242. COPY_STRING_FIELD(portalname);
  2243. return newnode;
  2244. }
  2245. static ClusterStmt *
  2246. _copyClusterStmt(const ClusterStmt *from)
  2247. {
  2248. ClusterStmt *newnode = makeNode(ClusterStmt);
  2249. COPY_NODE_FIELD(relation);
  2250. COPY_STRING_FIELD(indexname);
  2251. COPY_SCALAR_FIELD(verbose);
  2252. return newnode;
  2253. }
  2254. static CopyStmt *
  2255. _copyCopyStmt(const CopyStmt *from)
  2256. {
  2257. CopyStmt *newnode = makeNode(CopyStmt);
  2258. COPY_NODE_FIELD(relation);
  2259. COPY_NODE_FIELD(query);
  2260. COPY_NODE_FIELD(attlist);
  2261. COPY_SCALAR_FIELD(is_from);
  2262. COPY_SCALAR_FIELD(is_program);
  2263. COPY_STRING_FIELD(filename);
  2264. COPY_NODE_FIELD(options);
  2265. return newnode;
  2266. }
  2267. /*
  2268. * CopyCreateStmtFields
  2269. *
  2270. * This function copies the fields of the CreateStmt node. It is used by
  2271. * copy functions for classes which inherit from CreateStmt.
  2272. */
  2273. static void
  2274. CopyCreateStmtFields(const CreateStmt *from, CreateStmt *newnode)
  2275. {
  2276. COPY_NODE_FIELD(relation);
  2277. COPY_NODE_FIELD(tableElts);
  2278. COPY_NODE_FIELD(inhRelations);
  2279. COPY_NODE_FIELD(ofTypename);
  2280. COPY_NODE_FIELD(constraints);
  2281. COPY_NODE_FIELD(options);
  2282. COPY_SCALAR_FIELD(oncommit);
  2283. COPY_STRING_FIELD(tablespacename);
  2284. COPY_SCALAR_FIELD(if_not_exists);
  2285. }
  2286. static CreateStmt *
  2287. _copyCreateStmt(const CreateStmt *from)
  2288. {
  2289. CreateStmt *newnode = makeNode(CreateStmt);
  2290. CopyCreateStmtFields(from, newnode);
  2291. return newnode;
  2292. }
  2293. static TableLikeClause *
  2294. _copyTableLikeClause(const TableLikeClause *from)
  2295. {
  2296. TableLikeClause *newnode = makeNode(TableLikeClause);
  2297. COPY_NODE_FIELD(relation);
  2298. COPY_SCALAR_FIELD(options);
  2299. return newnode;
  2300. }
  2301. static DefineStmt *
  2302. _copyDefineStmt(const DefineStmt *from)
  2303. {
  2304. DefineStmt *newnode = makeNode(DefineStmt);
  2305. COPY_SCALAR_FIELD(kind);
  2306. COPY_SCALAR_FIELD(oldstyle);
  2307. COPY_NODE_FIELD(defnames);
  2308. COPY_NODE_FIELD(args);
  2309. COPY_NODE_FIELD(definition);
  2310. return newnode;
  2311. }
  2312. static DropStmt *
  2313. _copyDropStmt(const DropStmt *from)
  2314. {
  2315. DropStmt *newnode = makeNode(DropStmt);
  2316. COPY_NODE_FIELD(objects);
  2317. COPY_NODE_FIELD(arguments);
  2318. COPY_SCALAR_FIELD(removeType);
  2319. COPY_SCALAR_FIELD(behavior);
  2320. COPY_SCALAR_FIELD(missing_ok);
  2321. COPY_SCALAR_FIELD(concurrent);
  2322. return newnode;
  2323. }
  2324. static TruncateStmt *
  2325. _copyTruncateStmt(const TruncateStmt *from)
  2326. {
  2327. TruncateStmt *newnode = makeNode(TruncateStmt);
  2328. COPY_NODE_FIELD(relations);
  2329. COPY_SCALAR_FIELD(restart_seqs);
  2330. COPY_SCALAR_FIELD(behavior);
  2331. return newnode;
  2332. }
  2333. static CommentStmt *
  2334. _copyCommentStmt(const CommentStmt *from)
  2335. {
  2336. CommentStmt *newnode = makeNode(CommentStmt);
  2337. COPY_SCALAR_FIELD(objtype);
  2338. COPY_NODE_FIELD(objname);
  2339. COPY_NODE_FIELD(objargs);
  2340. COPY_STRING_FIELD(comment);
  2341. return newnode;
  2342. }
  2343. static SecLabelStmt *
  2344. _copySecLabelStmt(const SecLabelStmt *from)
  2345. {
  2346. SecLabelStmt *newnode = makeNode(SecLabelStmt);
  2347. COPY_SCALAR_FIELD(objtype);
  2348. COPY_NODE_FIELD(objname);
  2349. COPY_NODE_FIELD(objargs);
  2350. COPY_STRING_FIELD(provider);
  2351. COPY_STRING_FIELD(label);
  2352. return newnode;
  2353. }
  2354. static FetchStmt *
  2355. _copyFetchStmt(const FetchStmt *from)
  2356. {
  2357. FetchStmt *newnode = makeNode(FetchStmt);
  2358. COPY_SCALAR_FIELD(direction);
  2359. COPY_SCALAR_FIELD(howMany);
  2360. COPY_STRING_FIELD(portalname);
  2361. COPY_SCALAR_FIELD(ismove);
  2362. return newnode;
  2363. }
  2364. static IndexStmt *
  2365. _copyIndexStmt(const IndexStmt *from)
  2366. {
  2367. IndexStmt *newnode = makeNode(IndexStmt);
  2368. COPY_STRING_FIELD(idxname);
  2369. COPY_NODE_FIELD(relation);
  2370. COPY_STRING_FIELD(accessMethod);
  2371. COPY_STRING_FIELD(tableSpace);
  2372. COPY_NODE_FIELD(indexParams);
  2373. COPY_NODE_FIELD(options);
  2374. COPY_NODE_FIELD(whereClause);
  2375. COPY_NODE_FIELD(excludeOpNames);
  2376. COPY_STRING_FIELD(idxcomment);
  2377. COPY_SCALAR_FIELD(indexOid);
  2378. COPY_SCALAR_FIELD(oldNode);
  2379. COPY_SCALAR_FIELD(unique);
  2380. COPY_SCALAR_FIELD(primary);
  2381. COPY_SCALAR_FIELD(isconstraint);
  2382. COPY_SCALAR_FIELD(deferrable);
  2383. COPY_SCALAR_FIELD(initdeferred);
  2384. COPY_SCALAR_FIELD(concurrent);
  2385. return newnode;
  2386. }
  2387. static CreateFunctionStmt *
  2388. _copyCreateFunctionStmt(const CreateFunctionStmt *from)
  2389. {
  2390. CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
  2391. COPY_SCALAR_FIELD(replace);
  2392. COPY_NODE_FIELD(funcname);
  2393. COPY_NODE_FIELD(parameters);
  2394. COPY_NODE_FIELD(returnType);
  2395. COPY_NODE_FIELD(options);
  2396. COPY_NODE_FIELD(withClause);
  2397. return newnode;
  2398. }
  2399. static FunctionParameter *
  2400. _copyFunctionParameter(const FunctionParameter *from)
  2401. {
  2402. FunctionParameter *newnode = makeNode(FunctionParameter);
  2403. COPY_STRING_FIELD(name);
  2404. COPY_NODE_FIELD(argType);
  2405. COPY_SCALAR_FIELD(mode);
  2406. COPY_NODE_FIELD(defexpr);
  2407. return newnode;
  2408. }
  2409. static AlterFunctionStmt *
  2410. _copyAlterFunctionStmt(const AlterFunctionStmt *from)
  2411. {
  2412. AlterFunctionStmt *newnode = makeNode(AlterFunctionStmt);
  2413. COPY_NODE_FIELD(func);
  2414. COPY_NODE_FIELD(actions);
  2415. return newnode;
  2416. }
  2417. static DoStmt *
  2418. _copyDoStmt(const DoStmt *from)
  2419. {
  2420. DoStmt *newnode = makeNode(DoStmt);
  2421. COPY_NODE_FIELD(args);
  2422. return newnode;
  2423. }
  2424. static RenameStmt *
  2425. _copyRenameStmt(const RenameStmt *from)
  2426. {
  2427. RenameStmt *newnode = makeNode(RenameStmt);
  2428. COPY_SCALAR_FIELD(renameType);
  2429. COPY_SCALAR_FIELD(relationType);
  2430. COPY_NODE_FIELD(relation);
  2431. COPY_NODE_FIELD(object);
  2432. COPY_NODE_FIELD(objarg);
  2433. COPY_STRING_FIELD(subname);
  2434. COPY_STRING_FIELD(newname);
  2435. COPY_SCALAR_FIELD(behavior);
  2436. COPY_SCALAR_FIELD(missing_ok);
  2437. return newnode;
  2438. }
  2439. static AlterObjectSchemaStmt *
  2440. _copyAlterObjectSchemaStmt(const AlterObjectSchemaStmt *from)
  2441. {
  2442. AlterObjectSchemaStmt *newnode = makeNode(AlterObjectSchemaStmt);
  2443. COPY_SCALAR_FIELD(objectType);
  2444. COPY_NODE_FIELD(relation);
  2445. COPY_NODE_FIELD(object);
  2446. COPY_NODE_FIELD(objarg);
  2447. COPY_STRING_FIELD(newschema);
  2448. COPY_SCALAR_FIELD(missing_ok);
  2449. return newnode;
  2450. }
  2451. static AlterOwnerStmt *
  2452. _copyAlterOwnerStmt(const AlterOwnerStmt *from)
  2453. {
  2454. AlterOwnerStmt *newnode = makeNode(AlterOwnerStmt);
  2455. COPY_SCALAR_FIELD(objectType);
  2456. COPY_NODE_FIELD(relation);
  2457. COPY_NODE_FIELD(object);
  2458. COPY_NODE_FIELD(objarg);
  2459. COPY_STRING_FIELD(newowner);
  2460. return newnode;
  2461. }
  2462. static RuleStmt *
  2463. _copyRuleStmt(const RuleStmt *from)
  2464. {
  2465. RuleStmt *newnode = makeNode(RuleStmt);
  2466. COPY_NODE_FIELD(relation);
  2467. COPY_STRING_FIELD(rulename);
  2468. COPY_NODE_FIELD(whereClause);
  2469. COPY_SCALAR_FIELD(event);
  2470. COPY_SCALAR_FIELD(instead);
  2471. COPY_NODE_FIELD(actions);
  2472. COPY_SCALAR_FIELD(replace);
  2473. return newnode;
  2474. }
  2475. static NotifyStmt *
  2476. _copyNotifyStmt(const NotifyStmt *from)
  2477. {
  2478. NotifyStmt *newnode = makeNode(NotifyStmt);
  2479. COPY_STRING_FIELD(conditionname);
  2480. COPY_STRING_FIELD(payload);
  2481. return newnode;
  2482. }
  2483. static ListenStmt *
  2484. _copyListenStmt(const ListenStmt *from)
  2485. {
  2486. ListenStmt *newnode = makeNode(ListenStmt);
  2487. COPY_STRING_FIELD(conditionname);
  2488. return newnode;
  2489. }
  2490. static UnlistenStmt *
  2491. _copyUnlistenStmt(const UnlistenStmt *from)
  2492. {
  2493. UnlistenStmt *newnode = makeNode(UnlistenStmt);
  2494. COPY_STRING_FIELD(conditionname);
  2495. return newnode;
  2496. }
  2497. static TransactionStmt *
  2498. _copyTransactionStmt(const TransactionStmt *from)
  2499. {
  2500. TransactionStmt *newnode = makeNode(TransactionStmt);
  2501. COPY_SCALAR_FIELD(kind);
  2502. COPY_NODE_FIELD(options);
  2503. COPY_STRING_FIELD(gid);
  2504. return newnode;
  2505. }
  2506. static CompositeTypeStmt *
  2507. _copyCompositeTypeStmt(const CompositeTypeStmt *from)
  2508. {
  2509. CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
  2510. COPY_NODE_FIELD(typevar);
  2511. COPY_NODE_FIELD(coldeflist);
  2512. return newnode;
  2513. }
  2514. static CreateEnumStmt *
  2515. _copyCreateEnumStmt(const CreateEnumStmt *from)
  2516. {
  2517. CreateEnumStmt *newnode = makeNode(CreateEnumStmt);
  2518. COPY_NODE_FIELD(typeName);
  2519. COPY_NODE_FIELD(vals);
  2520. return newnode;
  2521. }
  2522. static CreateRangeStmt *
  2523. _copyCreateRangeStmt(const CreateRangeStmt *from)
  2524. {
  2525. CreateRangeStmt *newnode = makeNode(CreateRangeStmt);
  2526. COPY_NODE_FIELD(typeName);
  2527. COPY_NODE_FIELD(params);
  2528. return newnode;
  2529. }
  2530. static AlterEnumStmt *
  2531. _copyAlterEnumStmt(const AlterEnumStmt *from)
  2532. {
  2533. AlterEnumStmt *newnode = makeNode(AlterEnumStmt);
  2534. COPY_NODE_FIELD(typeName);
  2535. COPY_STRING_FIELD(newVal);
  2536. COPY_STRING_FIELD(newValNeighbor);
  2537. COPY_SCALAR_FIELD(newValIsAfter);
  2538. COPY_SCALAR_FIELD(skipIfExists);
  2539. return newnode;
  2540. }
  2541. static ViewStmt *
  2542. _copyViewStmt(const ViewStmt *from)
  2543. {
  2544. ViewStmt *newnode = makeNode(ViewStmt);
  2545. COPY_NODE_FIELD(view);
  2546. COPY_NODE_FIELD(aliases);
  2547. COPY_NODE_FIELD(query);
  2548. COPY_SCALAR_FIELD(replace);
  2549. COPY_NODE_FIELD(options);
  2550. COPY_SCALAR_FIELD(withCheckOption);
  2551. return newnode;
  2552. }
  2553. static LoadStmt *
  2554. _copyLoadStmt(const LoadStmt *from)
  2555. {
  2556. LoadStmt *newnode = makeNode(LoadStmt);
  2557. COPY_STRING_FIELD(filename);
  2558. return newnode;
  2559. }
  2560. static CreateDomainStmt *
  2561. _copyCreateDomainStmt(const CreateDomainStmt *from)
  2562. {
  2563. CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
  2564. COPY_NODE_FIELD(domainname);
  2565. COPY_NODE_FIELD(typeName);
  2566. COPY_NODE_FIELD(collClause);
  2567. COPY_NODE_FIELD(constraints);
  2568. return newnode;
  2569. }
  2570. static CreateOpClassStmt *
  2571. _copyCreateOpClassStmt(const CreateOpClassStmt *from)
  2572. {
  2573. CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
  2574. COPY_NODE_FIELD(opclassname);
  2575. COPY_NODE_FIELD(opfamilyname);
  2576. COPY_STRING_FIELD(amname);
  2577. COPY_NODE_FIELD(datatype);
  2578. COPY_NODE_FIELD(items);
  2579. COPY_SCALAR_FIELD(isDefault);
  2580. return newnode;
  2581. }
  2582. static CreateOpClassItem *
  2583. _copyCreateOpClassItem(const CreateOpClassItem *from)
  2584. {
  2585. CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
  2586. COPY_SCALAR_FIELD(itemtype);
  2587. COPY_NODE_FIELD(name);
  2588. COPY_NODE_FIELD(args);
  2589. COPY_SCALAR_FIELD(number);
  2590. COPY_NODE_FIELD(order_family);
  2591. COPY_NODE_FIELD(class_args);
  2592. COPY_NODE_FIELD(storedtype);
  2593. return newnode;
  2594. }
  2595. static CreateOpFamilyStmt *
  2596. _copyCreateOpFamilyStmt(const CreateOpFamilyStmt *from)
  2597. {
  2598. CreateOpFamilyStmt *newnode = makeNode(CreateOpFamilyStmt);
  2599. COPY_NODE_FIELD(opfamilyname);
  2600. COPY_STRING_FIELD(amname);
  2601. return newnode;
  2602. }
  2603. static AlterOpFamilyStmt *
  2604. _copyAlterOpFamilyStmt(const AlterOpFamilyStmt *from)
  2605. {
  2606. AlterOpFamilyStmt *newnode = makeNode(AlterOpFamilyStmt);
  2607. COPY_NODE_FIELD(opfamilyname);
  2608. COPY_STRING_FIELD(amname);
  2609. COPY_SCALAR_FIELD(isDrop);
  2610. COPY_NODE_FIELD(items);
  2611. return newnode;
  2612. }
  2613. static CreatedbStmt *
  2614. _copyCreatedbStmt(const CreatedbStmt *from)
  2615. {
  2616. CreatedbStmt *newnode = makeNode(CreatedbStmt);
  2617. COPY_STRING_FIELD(dbname);
  2618. COPY_NODE_FIELD(options);
  2619. return newnode;
  2620. }
  2621. static AlterDatabaseStmt *
  2622. _copyAlterDatabaseStmt(const AlterDatabaseStmt *from)
  2623. {
  2624. AlterDatabaseStmt *newnode = makeNode(AlterDatabaseStmt);
  2625. COPY_STRING_FIELD(dbname);
  2626. COPY_NODE_FIELD(options);
  2627. return newnode;
  2628. }
  2629. static AlterDatabaseSetStmt *
  2630. _copyAlterDatabaseSetStmt(const AlterDatabaseSetStmt *from)
  2631. {
  2632. AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
  2633. COPY_STRING_FIELD(dbname);
  2634. COPY_NODE_FIELD(setstmt);
  2635. return newnode;
  2636. }
  2637. static DropdbStmt *
  2638. _copyDropdbStmt(const DropdbStmt *from)
  2639. {
  2640. DropdbStmt *newnode = makeNode(DropdbStmt);
  2641. COPY_STRING_FIELD(dbname);
  2642. COPY_SCALAR_FIELD(missing_ok);
  2643. return newnode;
  2644. }
  2645. static VacuumStmt *
  2646. _copyVacuumStmt(const VacuumStmt *from)
  2647. {
  2648. VacuumStmt *newnode = makeNode(VacuumStmt);
  2649. COPY_SCALAR_FIELD(options);
  2650. COPY_SCALAR_FIELD(freeze_min_age);
  2651. COPY_SCALAR_FIELD(freeze_table_age);
  2652. COPY_SCALAR_FIELD(multixact_freeze_min_age);
  2653. COPY_SCALAR_FIELD(multixact_freeze_table_age);
  2654. COPY_NODE_FIELD(relation);
  2655. COPY_NODE_FIELD(va_cols);
  2656. return newnode;
  2657. }
  2658. static ExplainStmt *
  2659. _copyExplainStmt(const ExplainStmt *from)
  2660. {
  2661. ExplainStmt *newnode = makeNode(ExplainStmt);
  2662. COPY_NODE_FIELD(query);
  2663. COPY_NODE_FIELD(options);
  2664. return newnode;
  2665. }
  2666. static CreateTableAsStmt *
  2667. _copyCreateTableAsStmt(const CreateTableAsStmt *from)
  2668. {
  2669. CreateTableAsStmt *newnode = makeNode(CreateTableAsStmt);
  2670. COPY_NODE_FIELD(query);
  2671. COPY_NODE_FIELD(into);
  2672. COPY_SCALAR_FIELD(relkind);
  2673. COPY_SCALAR_FIELD(is_select_into);
  2674. return newnode;
  2675. }
  2676. static RefreshMatViewStmt *
  2677. _copyRefreshMatViewStmt(const RefreshMatViewStmt *from)
  2678. {
  2679. RefreshMatViewStmt *newnode = makeNode(RefreshMatViewStmt);
  2680. COPY_SCALAR_FIELD(concurrent);
  2681. COPY_SCALAR_FIELD(skipData);
  2682. COPY_NODE_FIELD(relation);
  2683. return newnode;
  2684. }
  2685. static ReplicaIdentityStmt *
  2686. _copyReplicaIdentityStmt(const ReplicaIdentityStmt *from)
  2687. {
  2688. ReplicaIdentityStmt *newnode = makeNode(ReplicaIdentityStmt);
  2689. COPY_SCALAR_FIELD(identity_type);
  2690. COPY_STRING_FIELD(name);
  2691. return newnode;
  2692. }
  2693. static AlterSystemStmt *
  2694. _copyAlterSystemStmt(const AlterSystemStmt *from)
  2695. {
  2696. AlterSystemStmt *newnode = makeNode(AlterSystemStmt);
  2697. COPY_NODE_FIELD(setstmt);
  2698. return newnode;
  2699. }
  2700. static CreateSeqStmt *
  2701. _copyCreateSeqStmt(const CreateSeqStmt *from)
  2702. {
  2703. CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
  2704. COPY_NODE_FIELD(sequence);
  2705. COPY_NODE_FIELD(options);
  2706. COPY_SCALAR_FIELD(ownerId);
  2707. return newnode;
  2708. }
  2709. static AlterSeqStmt *
  2710. _copyAlterSeqStmt(const AlterSeqStmt *from)
  2711. {
  2712. AlterSeqStmt *newnode = makeNode(AlterSeqStmt);
  2713. COPY_NODE_FIELD(sequence);
  2714. COPY_NODE_FIELD(options);
  2715. COPY_SCALAR_FIELD(missing_ok);
  2716. return newnode;
  2717. }
  2718. static VariableSetStmt *
  2719. _copyVariableSetStmt(const VariableSetStmt *from)
  2720. {
  2721. VariableSetStmt *newnode = makeNode(VariableSetStmt);
  2722. COPY_SCALAR_FIELD(kind);
  2723. COPY_STRING_FIELD(name);
  2724. COPY_NODE_FIELD(args);
  2725. COPY_SCALAR_FIELD(is_local);
  2726. return newnode;
  2727. }
  2728. static VariableShowStmt *
  2729. _copyVariableShowStmt(const VariableShowStmt *from)
  2730. {
  2731. VariableShowStmt *newnode = makeNode(VariableShowStmt);
  2732. COPY_STRING_FIELD(name);
  2733. return newnode;
  2734. }
  2735. static DiscardStmt *
  2736. _copyDiscardStmt(const DiscardStmt *from)
  2737. {
  2738. DiscardStmt *newnode = makeNode(DiscardStmt);
  2739. COPY_SCALAR_FIELD(target);
  2740. return newnode;
  2741. }
  2742. static CreateTableSpaceStmt *
  2743. _copyCreateTableSpaceStmt(const CreateTableSpaceStmt *from)
  2744. {
  2745. CreateTableSpaceStmt *newnode = makeNode(CreateTableSpaceStmt);
  2746. COPY_STRING_FIELD(tablespacename);
  2747. COPY_STRING_FIELD(owner);
  2748. COPY_STRING_FIELD(location);
  2749. COPY_NODE_FIELD(options);
  2750. return newnode;
  2751. }
  2752. static DropTableSpaceStmt *
  2753. _copyDropTableSpaceStmt(const DropTableSpaceStmt *from)
  2754. {
  2755. DropTableSpaceStmt *newnode = makeNode(DropTableSpaceStmt);
  2756. COPY_STRING_FIELD(tablespacename);
  2757. COPY_SCALAR_FIELD(missing_ok);
  2758. return newnode;
  2759. }
  2760. static AlterTableSpaceOptionsStmt *
  2761. _copyAlterTableSpaceOptionsStmt(const AlterTableSpaceOptionsStmt *from)
  2762. {
  2763. AlterTableSpaceOptionsStmt *newnode = makeNode(AlterTableSpaceOptionsStmt);
  2764. COPY_STRING_FIELD(tablespacename);
  2765. COPY_NODE_FIELD(options);
  2766. COPY_SCALAR_FIELD(isReset);
  2767. return newnode;
  2768. }
  2769. static AlterTableSpaceMoveStmt *
  2770. _copyAlterTableSpaceMoveStmt(const AlterTableSpaceMoveStmt *from)
  2771. {
  2772. AlterTableSpaceMoveStmt *newnode = makeNode(AlterTableSpaceMoveStmt);
  2773. COPY_STRING_FIELD(orig_tablespacename);
  2774. COPY_SCALAR_FIELD(objtype);
  2775. COPY_SCALAR_FIELD(move_all);
  2776. COPY_NODE_FIELD(roles);
  2777. COPY_STRING_FIELD(new_tablespacename);
  2778. COPY_SCALAR_FIELD(nowait);
  2779. return newnode;
  2780. }
  2781. static CreateExtensionStmt *
  2782. _copyCreateExtensionStmt(const CreateExtensionStmt *from)
  2783. {
  2784. CreateExtensionStmt *newnode = makeNode(CreateExtensionStmt);
  2785. COPY_STRING_FIELD(extname);
  2786. COPY_SCALAR_FIELD(if_not_exists);
  2787. COPY_NODE_FIELD(options);
  2788. return newnode;
  2789. }
  2790. static AlterExtensionStmt *
  2791. _copyAlterExtensionStmt(const AlterExtensionStmt *from)
  2792. {
  2793. AlterExtensionStmt *newnode = makeNode(AlterExtensionStmt);
  2794. COPY_STRING_FIELD(extname);
  2795. COPY_NODE_FIELD(options);
  2796. return newnode;
  2797. }
  2798. static AlterExtensionContentsStmt *
  2799. _copyAlterExtensionContentsStmt(const AlterExtensionContentsStmt *from)
  2800. {
  2801. AlterExtensionContentsStmt *newnode = makeNode(AlterExtensionContentsStmt);
  2802. COPY_STRING_FIELD(extname);
  2803. COPY_SCALAR_FIELD(action);
  2804. COPY_SCALAR_FIELD(objtype);
  2805. COPY_NODE_FIELD(objname);
  2806. COPY_NODE_FIELD(objargs);
  2807. return newnode;
  2808. }
  2809. static CreateFdwStmt *
  2810. _copyCreateFdwStmt(const CreateFdwStmt *from)
  2811. {
  2812. CreateFdwStmt *newnode = makeNode(CreateFdwStmt);
  2813. COPY_STRING_FIELD(fdwname);
  2814. COPY_NODE_FIELD(func_options);
  2815. COPY_NODE_FIELD(options);
  2816. return newnode;
  2817. }
  2818. static AlterFdwStmt *
  2819. _copyAlterFdwStmt(const AlterFdwStmt *from)
  2820. {
  2821. AlterFdwStmt *newnode = makeNode(AlterFdwStmt);
  2822. COPY_STRING_FIELD(fdwname);
  2823. COPY_NODE_FIELD(func_options);
  2824. COPY_NODE_FIELD(options);
  2825. return newnode;
  2826. }
  2827. static CreateForeignServerStmt *
  2828. _copyCreateForeignServerStmt(const CreateForeignServerStmt *from)
  2829. {
  2830. CreateForeignServerStmt *newnode = makeNode(CreateForeignServerStmt);
  2831. COPY_STRING_FIELD(servername);
  2832. COPY_STRING_FIELD(servertype);
  2833. COPY_STRING_FIELD(version);
  2834. COPY_STRING_FIELD(fdwname);
  2835. COPY_NODE_FIELD(options);
  2836. return newnode;
  2837. }
  2838. static AlterForeignServerStmt *
  2839. _copyAlterForeignServerStmt(const AlterForeignServerStmt *from)
  2840. {
  2841. AlterForeignServerStmt *newnode = makeNode(AlterForeignServerStmt);
  2842. COPY_STRING_FIELD(servername);
  2843. COPY_STRING_FIELD(version);
  2844. COPY_NODE_FIELD(options);
  2845. COPY_SCALAR_FIELD(has_version);
  2846. return newnode;
  2847. }
  2848. static CreateUserMappingStmt *
  2849. _copyCreateUserMappingStmt(const CreateUserMappingStmt *from)
  2850. {
  2851. CreateUserMappingStmt *newnode = makeNode(CreateUserMappingStmt);
  2852. COPY_STRING_FIELD(username);
  2853. COPY_STRING_FIELD(servername);
  2854. COPY_NODE_FIELD(options);
  2855. return newnode;
  2856. }
  2857. static AlterUserMappingStmt *
  2858. _copyAlterUserMappingStmt(const AlterUserMappingStmt *from)
  2859. {
  2860. AlterUserMappingStmt *newnode = makeNode(AlterUserMappingStmt);
  2861. COPY_STRING_FIELD(username);
  2862. COPY_STRING_FIELD(servername);
  2863. COPY_NODE_FIELD(options);
  2864. return newnode;
  2865. }
  2866. static DropUserMappingStmt *
  2867. _copyDropUserMappingStmt(const DropUserMappingStmt *from)
  2868. {
  2869. DropUserMappingStmt *newnode = makeNode(DropUserMappingStmt);
  2870. COPY_STRING_FIELD(username);
  2871. COPY_STRING_FIELD(servername);
  2872. COPY_SCALAR_FIELD(missing_ok);
  2873. return newnode;
  2874. }
  2875. static CreateForeignTableStmt *
  2876. _copyCreateForeignTableStmt(const CreateForeignTableStmt *from)
  2877. {
  2878. CreateForeignTableStmt *newnode = makeNode(CreateForeignTableStmt);
  2879. CopyCreateStmtFields((const CreateStmt *) from, (CreateStmt *) newnode);
  2880. COPY_STRING_FIELD(servername);
  2881. COPY_NODE_FIELD(options);
  2882. return newnode;
  2883. }
  2884. static CreateTrigStmt *
  2885. _copyCreateTrigStmt(const CreateTrigStmt *from)
  2886. {
  2887. CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
  2888. COPY_STRING_FIELD(trigname);
  2889. COPY_NODE_FIELD(relation);
  2890. COPY_NODE_FIELD(funcname);
  2891. COPY_NODE_FIELD(args);
  2892. COPY_SCALAR_FIELD(row);
  2893. COPY_SCALAR_FIELD(timing);
  2894. COPY_SCALAR_FIELD(events);
  2895. COPY_NODE_FIELD(columns);
  2896. COPY_NODE_FIELD(whenClause);
  2897. COPY_SCALAR_FIELD(isconstraint);
  2898. COPY_SCALAR_FIELD(deferrable);
  2899. COPY_SCALAR_FIELD(initdeferred);
  2900. COPY_NODE_FIELD(constrrel);
  2901. return newnode;
  2902. }
  2903. static CreateEventTrigStmt *
  2904. _copyCreateEventTrigStmt(const CreateEventTrigStmt *from)
  2905. {
  2906. CreateEventTrigStmt *newnode = makeNode(CreateEventTrigStmt);
  2907. COPY_STRING_FIELD(trigname);
  2908. COPY_SCALAR_FIELD(eventname);
  2909. COPY_NODE_FIELD(whenclause);
  2910. COPY_NODE_FIELD(funcname);
  2911. return newnode;
  2912. }
  2913. static AlterEventTrigStmt *
  2914. _copyAlterEventTrigStmt(const AlterEventTrigStmt *from)
  2915. {
  2916. AlterEventTrigStmt *newnode = makeNode(AlterEventTrigStmt);
  2917. COPY_STRING_FIELD(trigname);
  2918. COPY_SCALAR_FIELD(tgenabled);
  2919. return newnode;
  2920. }
  2921. static CreatePLangStmt *
  2922. _copyCreatePLangStmt(const CreatePLangStmt *from)
  2923. {
  2924. CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
  2925. COPY_SCALAR_FIELD(replace);
  2926. COPY_STRING_FIELD(plname);
  2927. COPY_NODE_FIELD(plhandler);
  2928. COPY_NODE_FIELD(plinline);
  2929. COPY_NODE_FIELD(plvalidator);
  2930. COPY_SCALAR_FIELD(pltrusted);
  2931. return newnode;
  2932. }
  2933. static CreateRoleStmt *
  2934. _copyCreateRoleStmt(const CreateRoleStmt *from)
  2935. {
  2936. CreateRoleStmt *newnode = makeNode(CreateRoleStmt);
  2937. COPY_SCALAR_FIELD(stmt_type);
  2938. COPY_STRING_FIELD(role);
  2939. COPY_NODE_FIELD(options);
  2940. return newnode;
  2941. }
  2942. static AlterRoleStmt *
  2943. _copyAlterRoleStmt(const AlterRoleStmt *from)
  2944. {
  2945. AlterRoleStmt *newnode = makeNode(AlterRoleStmt);
  2946. COPY_STRING_FIELD(role);
  2947. COPY_NODE_FIELD(options);
  2948. COPY_SCALAR_FIELD(action);
  2949. return newnode;
  2950. }
  2951. static AlterRoleSetStmt *
  2952. _copyAlterRoleSetStmt(const AlterRoleSetStmt *from)
  2953. {
  2954. AlterRoleSetStmt *newnode = makeNode(AlterRoleSetStmt);
  2955. COPY_STRING_FIELD(role);
  2956. COPY_STRING_FIELD(database);
  2957. COPY_NODE_FIELD(setstmt);
  2958. return newnode;
  2959. }
  2960. static DropRoleStmt *
  2961. _copyDropRoleStmt(const DropRoleStmt *from)
  2962. {
  2963. DropRoleStmt *newnode = makeNode(DropRoleStmt);
  2964. COPY_NODE_FIELD(roles);
  2965. COPY_SCALAR_FIELD(missing_ok);
  2966. return newnode;
  2967. }
  2968. static LockStmt *
  2969. _copyLockStmt(const LockStmt *from)
  2970. {
  2971. LockStmt *newnode = makeNode(LockStmt);
  2972. COPY_NODE_FIELD(relations);
  2973. COPY_SCALAR_FIELD(mode);
  2974. COPY_SCALAR_FIELD(nowait);
  2975. return newnode;
  2976. }
  2977. static ConstraintsSetStmt *
  2978. _copyConstraintsSetStmt(const ConstraintsSetStmt *from)
  2979. {
  2980. ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
  2981. COPY_NODE_FIELD(constraints);
  2982. COPY_SCALAR_FIELD(deferred);
  2983. return newnode;
  2984. }
  2985. static ReindexStmt *
  2986. _copyReindexStmt(const ReindexStmt *from)
  2987. {
  2988. ReindexStmt *newnode = makeNode(ReindexStmt);
  2989. COPY_SCALAR_FIELD(kind);
  2990. COPY_NODE_FIELD(relation);
  2991. COPY_STRING_FIELD(name);
  2992. COPY_SCALAR_FIELD(do_system);
  2993. COPY_SCALAR_FIELD(do_user);
  2994. return newnode;
  2995. }
  2996. static CreateSchemaStmt *
  2997. _copyCreateSchemaStmt(const CreateSchemaStmt *from)
  2998. {
  2999. CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
  3000. COPY_STRING_FIELD(schemaname);
  3001. COPY_STRING_FIELD(authid);
  3002. COPY_NODE_FIELD(schemaElts);
  3003. COPY_SCALAR_FIELD(if_not_exists);
  3004. return newnode;
  3005. }
  3006. static CreateConversionStmt *
  3007. _copyCreateConversionStmt(const CreateConversionStmt *from)
  3008. {
  3009. CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
  3010. COPY_NODE_FIELD(conversion_name);
  3011. COPY_STRING_FIELD(for_encoding_name);
  3012. COPY_STRING_FIELD(to_encoding_name);
  3013. COPY_NODE_FIELD(func_name);
  3014. COPY_SCALAR_FIELD(def);
  3015. return newnode;
  3016. }
  3017. static CreateCastStmt *
  3018. _copyCreateCastStmt(const CreateCastStmt *from)
  3019. {
  3020. CreateCastStmt *newnode = makeNode(CreateCastStmt);
  3021. COPY_NODE_FIELD(sourcetype);
  3022. COPY_NODE_FIELD(targettype);
  3023. COPY_NODE_FIELD(func);
  3024. COPY_SCALAR_FIELD(context);
  3025. COPY_SCALAR_FIELD(inout);
  3026. return newnode;
  3027. }
  3028. static PrepareStmt *
  3029. _copyPrepareStmt(const PrepareStmt *from)
  3030. {
  3031. PrepareStmt *newnode = makeNode(PrepareStmt);
  3032. COPY_STRING_FIELD(name);
  3033. COPY_NODE_FIELD(argtypes);
  3034. COPY_NODE_FIELD(query);
  3035. return newnode;
  3036. }
  3037. static ExecuteStmt *
  3038. _copyExecuteStmt(const ExecuteStmt *from)
  3039. {
  3040. ExecuteStmt *newnode = makeNode(ExecuteStmt);
  3041. COPY_STRING_FIELD(name);
  3042. COPY_NODE_FIELD(params);
  3043. return newnode;
  3044. }
  3045. static DeallocateStmt *
  3046. _copyDeallocateStmt(const DeallocateStmt *from)
  3047. {
  3048. DeallocateStmt *newnode = makeNode(DeallocateStmt);
  3049. COPY_STRING_FIELD(name);
  3050. return newnode;
  3051. }
  3052. static DropOwnedStmt *
  3053. _copyDropOwnedStmt(const DropOwnedStmt *from)
  3054. {
  3055. DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
  3056. COPY_NODE_FIELD(roles);
  3057. COPY_SCALAR_FIELD(behavior);
  3058. return newnode;
  3059. }
  3060. static ReassignOwnedStmt *
  3061. _copyReassignOwnedStmt(const ReassignOwnedStmt *from)
  3062. {
  3063. ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
  3064. COPY_NODE_FIELD(roles);
  3065. COPY_STRING_FIELD(newrole);
  3066. return newnode;
  3067. }
  3068. static AlterTSDictionaryStmt *
  3069. _copyAlterTSDictionaryStmt(const AlterTSDictionaryStmt *from)
  3070. {
  3071. AlterTSDictionaryStmt *newnode = makeNode(AlterTSDictionaryStmt);
  3072. COPY_NODE_FIELD(dictname);
  3073. COPY_NODE_FIELD(options);
  3074. return newnode;
  3075. }
  3076. static AlterTSConfigurationStmt *
  3077. _copyAlterTSConfigurationStmt(const AlterTSConfigurationStmt *from)
  3078. {
  3079. AlterTSConfigurationStmt *newnode = makeNode(AlterTSConfigurationStmt);
  3080. COPY_NODE_FIELD(cfgname);
  3081. COPY_NODE_FIELD(tokentype);
  3082. COPY_NODE_FIELD(dicts);
  3083. COPY_SCALAR_FIELD(override);
  3084. COPY_SCALAR_FIELD(replace);
  3085. COPY_SCALAR_FIELD(missing_ok);
  3086. return newnode;
  3087. }
  3088. /* ****************************************************************
  3089. * pg_list.h copy functions
  3090. * ****************************************************************
  3091. */
  3092. /*
  3093. * Perform a deep copy of the specified list, using copyObject(). The
  3094. * list MUST be of type T_List; T_IntList and T_OidList nodes don't
  3095. * need deep copies, so they should be copied via list_copy()
  3096. */
  3097. #define COPY_NODE_CELL(new, old) \
  3098. (new) = (ListCell *) palloc(sizeof(ListCell)); \
  3099. lfirst(new) = copyObject(lfirst(old));
  3100. static List *
  3101. _copyList(const List *from)
  3102. {
  3103. List *new;
  3104. ListCell *curr_old;
  3105. ListCell *prev_new;
  3106. Assert(list_length(from) >= 1);
  3107. new = makeNode(List);
  3108. new->length = from->length;
  3109. COPY_NODE_CELL(new->head, from->head);
  3110. prev_new = new->head;
  3111. curr_old = lnext(from->head);
  3112. while (curr_old)
  3113. {
  3114. COPY_NODE_CELL(prev_new->next, curr_old);
  3115. prev_new = prev_new->next;
  3116. curr_old = curr_old->next;
  3117. }
  3118. prev_new->next = NULL;
  3119. new->tail = prev_new;
  3120. return new;
  3121. }
  3122. /* ****************************************************************
  3123. * value.h copy functions
  3124. * ****************************************************************
  3125. */
  3126. static Value *
  3127. _copyValue(const Value *from)
  3128. {
  3129. Value *newnode = makeNode(Value);
  3130. /* See also _copyAConst when changing this code! */
  3131. COPY_SCALAR_FIELD(type);
  3132. switch (from->type)
  3133. {
  3134. case T_Integer:
  3135. COPY_SCALAR_FIELD(val.ival);
  3136. break;
  3137. case T_Float:
  3138. case T_String:
  3139. case T_BitString:
  3140. COPY_STRING_FIELD(val.str);
  3141. break;
  3142. case T_Null:
  3143. /* nothing to do */
  3144. break;
  3145. default:
  3146. elog(ERROR, "unrecognized node type: %d",
  3147. (int) from->type);
  3148. break;
  3149. }
  3150. return newnode;
  3151. }
  3152. /*
  3153. * copyObject
  3154. *
  3155. * Create a copy of a Node tree or list. This is a "deep" copy: all
  3156. * substructure is copied too, recursively.
  3157. */
  3158. void *
  3159. copyObject(const void *from)
  3160. {
  3161. void *retval;
  3162. if (from == NULL)
  3163. return NULL;
  3164. /* Guard against stack overflow due to overly complex expressions */
  3165. check_stack_depth();
  3166. switch (nodeTag(from))
  3167. {
  3168. /*
  3169. * PLAN NODES
  3170. */
  3171. case T_PlannedStmt:
  3172. retval = _copyPlannedStmt(from);
  3173. break;
  3174. case T_Plan:
  3175. retval = _copyPlan(from);
  3176. break;
  3177. case T_Result:
  3178. retval = _copyResult(from);
  3179. break;
  3180. case T_ModifyTable:
  3181. retval = _copyModifyTable(from);
  3182. break;
  3183. case T_Append:
  3184. retval = _copyAppend(from);
  3185. break;
  3186. case T_MergeAppend:
  3187. retval = _copyMergeAppend(from);
  3188. break;
  3189. case T_RecursiveUnion:
  3190. retval = _copyRecursiveUnion(from);
  3191. break;
  3192. case T_BitmapAnd:
  3193. retval = _copyBitmapAnd(from);
  3194. break;
  3195. case T_BitmapOr:
  3196. retval = _copyBitmapOr(from);
  3197. break;
  3198. case T_Scan:
  3199. retval = _copyScan(from);
  3200. break;
  3201. case T_SeqScan:
  3202. retval = _copySeqScan(from);
  3203. break;
  3204. case T_IndexScan:
  3205. retval = _copyIndexScan(from);
  3206. break;
  3207. case T_IndexOnlyScan:
  3208. retval = _copyIndexOnlyScan(from);
  3209. break;
  3210. case T_BitmapIndexScan:
  3211. retval = _copyBitmapIndexScan(from);
  3212. break;
  3213. case T_BitmapHeapScan:
  3214. retval = _copyBitmapHeapScan(from);
  3215. break;
  3216. case T_TidScan:
  3217. retval = _copyTidScan(from);
  3218. break;
  3219. case T_SubqueryScan:
  3220. retval = _copySubqueryScan(from);
  3221. break;
  3222. case T_FunctionScan:
  3223. retval = _copyFunctionScan(from);
  3224. break;
  3225. case T_ValuesScan:
  3226. retval = _copyValuesScan(from);
  3227. break;
  3228. case T_CteScan:
  3229. retval = _copyCteScan(from);
  3230. break;
  3231. case T_WorkTableScan:
  3232. retval = _copyWorkTableScan(from);
  3233. break;
  3234. case T_ForeignScan:
  3235. retval = _copyForeignScan(from);
  3236. break;
  3237. case T_Join:
  3238. retval = _copyJoin(from);
  3239. break;
  3240. case T_NestLoop:
  3241. retval = _copyNestLoop(from);
  3242. break;
  3243. case T_MergeJoin:
  3244. retval = _copyMergeJoin(from);
  3245. break;
  3246. case T_HashJoin:
  3247. retval = _copyHashJoin(from);
  3248. break;
  3249. case T_Material:
  3250. retval = _copyMaterial(from);
  3251. break;
  3252. case T_Sort:
  3253. retval = _copySort(from);
  3254. break;
  3255. case T_Group:
  3256. retval = _copyGroup(from);
  3257. break;
  3258. case T_Agg:
  3259. retval = _copyAgg(from);
  3260. break;
  3261. case T_WindowAgg:
  3262. retval = _copyWindowAgg(from);
  3263. break;
  3264. case T_Unique:
  3265. retval = _copyUnique(from);
  3266. break;
  3267. case T_Hash:
  3268. retval = _copyHash(from);
  3269. break;
  3270. case T_SetOp:
  3271. retval = _copySetOp(from);
  3272. break;
  3273. case T_LockRows:
  3274. retval = _copyLockRows(from);
  3275. break;
  3276. case T_Limit:
  3277. retval = _copyLimit(from);
  3278. break;
  3279. case T_NestLoopParam:
  3280. retval = _copyNestLoopParam(from);
  3281. break;
  3282. case T_PlanRowMark:
  3283. retval = _copyPlanRowMark(from);
  3284. break;
  3285. case T_PlanInvalItem:
  3286. retval = _copyPlanInvalItem(from);
  3287. break;
  3288. /*
  3289. * PRIMITIVE NODES
  3290. */
  3291. case T_Alias:
  3292. retval = _copyAlias(from);
  3293. break;
  3294. case T_RangeVar:
  3295. retval = _copyRangeVar(from);
  3296. break;
  3297. case T_IntoClause:
  3298. retval = _copyIntoClause(from);
  3299. break;
  3300. case T_Var:
  3301. retval = _copyVar(from);
  3302. break;
  3303. case T_Const:
  3304. retval = _copyConst(from);
  3305. break;
  3306. case T_Param:
  3307. retval = _copyParam(from);
  3308. break;
  3309. case T_Aggref:
  3310. retval = _copyAggref(from);
  3311. break;
  3312. case T_WindowFunc:
  3313. retval = _copyWindowFunc(from);
  3314. break;
  3315. case T_ArrayRef:
  3316. retval = _copyArrayRef(from);
  3317. break;
  3318. case T_FuncExpr:
  3319. retval = _copyFuncExpr(from);
  3320. break;
  3321. case T_NamedArgExpr:
  3322. retval = _copyNamedArgExpr(from);
  3323. break;
  3324. case T_OpExpr:
  3325. retval = _copyOpExpr(from);
  3326. break;
  3327. case T_DistinctExpr:
  3328. retval = _copyDistinctExpr(from);
  3329. break;
  3330. case T_NullIfExpr:
  3331. retval = _copyNullIfExpr(from);
  3332. break;
  3333. case T_ScalarArrayOpExpr:
  3334. retval = _copyScalarArrayOpExpr(from);
  3335. break;
  3336. case T_BoolExpr:
  3337. retval = _copyBoolExpr(from);
  3338. break;
  3339. case T_SubLink:
  3340. retval = _copySubLink(from);
  3341. break;
  3342. case T_SubPlan:
  3343. retval = _copySubPlan(from);
  3344. break;
  3345. case T_AlternativeSubPlan:
  3346. retval = _copyAlternativeSubPlan(from);
  3347. break;
  3348. case T_FieldSelect:
  3349. retval = _copyFieldSelect(from);
  3350. break;
  3351. case T_FieldStore:
  3352. retval = _copyFieldStore(from);
  3353. break;
  3354. case T_RelabelType:
  3355. retval = _copyRelabelType(from);
  3356. break;
  3357. case T_CoerceViaIO:
  3358. retval = _copyCoerceViaIO(from);
  3359. break;
  3360. case T_ArrayCoerceExpr:
  3361. retval = _copyArrayCoerceExpr(from);
  3362. break;
  3363. case T_ConvertRowtypeExpr:
  3364. retval = _copyConvertRowtypeExpr(from);
  3365. break;
  3366. case T_CollateExpr:
  3367. retval = _copyCollateExpr(from);
  3368. break;
  3369. case T_CaseExpr:
  3370. retval = _copyCaseExpr(from);
  3371. break;
  3372. case T_CaseWhen:
  3373. retval = _copyCaseWhen(from);
  3374. break;
  3375. case T_CaseTestExpr:
  3376. retval = _copyCaseTestExpr(from);
  3377. break;
  3378. case T_ArrayExpr:
  3379. retval = _copyArrayExpr(from);
  3380. break;
  3381. case T_RowExpr:
  3382. retval = _copyRowExpr(from);
  3383. break;
  3384. case T_RowCompareExpr:
  3385. retval = _copyRowCompareExpr(from);
  3386. break;
  3387. case T_CoalesceExpr:
  3388. retval = _copyCoalesceExpr(from);
  3389. break;
  3390. case T_MinMaxExpr:
  3391. retval = _copyMinMaxExpr(from);
  3392. break;
  3393. case T_XmlExpr:
  3394. retval = _copyXmlExpr(from);
  3395. break;
  3396. case T_NullTest:
  3397. retval = _copyNullTest(from);
  3398. break;
  3399. case T_BooleanTest:
  3400. retval = _copyBooleanTest(from);
  3401. break;
  3402. case T_CoerceToDomain:
  3403. retval = _copyCoerceToDomain(from);
  3404. break;
  3405. case T_CoerceToDomainValue:
  3406. retval = _copyCoerceToDomainValue(from);
  3407. break;
  3408. case T_SetToDefault:
  3409. retval = _copySetToDefault(from);
  3410. break;
  3411. case T_CurrentOfExpr:
  3412. retval = _copyCurrentOfExpr(from);
  3413. break;
  3414. case T_TargetEntry:
  3415. retval = _copyTargetEntry(from);
  3416. break;
  3417. case T_RangeTblRef:
  3418. retval = _copyRangeTblRef(from);
  3419. break;
  3420. case T_JoinExpr:
  3421. retval = _copyJoinExpr(from);
  3422. break;
  3423. case T_FromExpr:
  3424. retval = _copyFromExpr(from);
  3425. break;
  3426. /*
  3427. * RELATION NODES
  3428. */
  3429. case T_PathKey:
  3430. retval = _copyPathKey(from);
  3431. break;
  3432. case T_RestrictInfo:
  3433. retval = _copyRestrictInfo(from);
  3434. break;
  3435. case T_PlaceHolderVar:
  3436. retval = _copyPlaceHolderVar(from);
  3437. break;
  3438. case T_SpecialJoinInfo:
  3439. retval = _copySpecialJoinInfo(from);
  3440. break;
  3441. case T_LateralJoinInfo:
  3442. retval = _copyLateralJoinInfo(from);
  3443. break;
  3444. case T_AppendRelInfo:
  3445. retval = _copyAppendRelInfo(from);
  3446. break;
  3447. case T_PlaceHolderInfo:
  3448. retval = _copyPlaceHolderInfo(from);
  3449. break;
  3450. /*
  3451. * VALUE NODES
  3452. */
  3453. case T_Integer:
  3454. case T_Float:
  3455. case T_String:
  3456. case T_BitString:
  3457. case T_Null:
  3458. retval = _copyValue(from);
  3459. break;
  3460. /*
  3461. * LIST NODES
  3462. */
  3463. case T_List:
  3464. retval = _copyList(from);
  3465. break;
  3466. /*
  3467. * Lists of integers and OIDs don't need to be deep-copied, so we
  3468. * perform a shallow copy via list_copy()
  3469. */
  3470. case T_IntList:
  3471. case T_OidList:
  3472. retval = list_copy(from);
  3473. break;
  3474. /*
  3475. * PARSE NODES
  3476. */
  3477. case T_Query:
  3478. retval = _copyQuery(from);
  3479. break;
  3480. case T_InsertStmt:
  3481. retval = _copyInsertStmt(from);
  3482. break;
  3483. case T_DeleteStmt:
  3484. retval = _copyDeleteStmt(from);
  3485. break;
  3486. case T_UpdateStmt:
  3487. retval = _copyUpdateStmt(from);
  3488. break;
  3489. case T_SelectStmt:
  3490. retval = _copySelectStmt(from);
  3491. break;
  3492. case T_SetOperationStmt:
  3493. retval = _copySetOperationStmt(from);
  3494. break;
  3495. case T_AlterTableStmt:
  3496. retval = _copyAlterTableStmt(from);
  3497. break;
  3498. case T_AlterTableCmd:
  3499. retval = _copyAlterTableCmd(from);
  3500. break;
  3501. case T_AlterDomainStmt:
  3502. retval = _copyAlterDomainStmt(from);
  3503. break;
  3504. case T_GrantStmt:
  3505. retval = _copyGrantStmt(from);
  3506. break;
  3507. case T_GrantRoleStmt:
  3508. retval = _copyGrantRoleStmt(from);
  3509. break;
  3510. case T_AlterDefaultPrivilegesStmt:
  3511. retval = _copyAlterDefaultPrivilegesStmt(from);
  3512. break;
  3513. case T_DeclareCursorStmt:
  3514. retval = _copyDeclareCursorStmt(from);
  3515. break;
  3516. case T_ClosePortalStmt:
  3517. retval = _copyClosePortalStmt(from);
  3518. break;
  3519. case T_ClusterStmt:
  3520. retval = _copyClusterStmt(from);
  3521. break;
  3522. case T_CopyStmt:
  3523. retval = _copyCopyStmt(from);
  3524. break;
  3525. case T_CreateStmt:
  3526. retval = _copyCreateStmt(from);
  3527. break;
  3528. case T_TableLikeClause:
  3529. retval = _copyTableLikeClause(from);
  3530. break;
  3531. case T_DefineStmt:
  3532. retval = _copyDefineStmt(from);
  3533. break;
  3534. case T_DropStmt:
  3535. retval = _copyDropStmt(from);
  3536. break;
  3537. case T_TruncateStmt:
  3538. retval = _copyTruncateStmt(from);
  3539. break;
  3540. case T_CommentStmt:
  3541. retval = _copyCommentStmt(from);
  3542. break;
  3543. case T_SecLabelStmt:
  3544. retval = _copySecLabelStmt(from);
  3545. break;
  3546. case T_FetchStmt:
  3547. retval = _copyFetchStmt(from);
  3548. break;
  3549. case T_IndexStmt:
  3550. retval = _copyIndexStmt(from);
  3551. break;
  3552. case T_CreateFunctionStmt:
  3553. retval = _copyCreateFunctionStmt(from);
  3554. break;
  3555. case T_FunctionParameter:
  3556. retval = _copyFunctionParameter(from);
  3557. break;
  3558. case T_AlterFunctionStmt:
  3559. retval = _copyAlterFunctionStmt(from);
  3560. break;
  3561. case T_DoStmt:
  3562. retval = _copyDoStmt(from);
  3563. break;
  3564. case T_RenameStmt:
  3565. retval = _copyRenameStmt(from);
  3566. break;
  3567. case T_AlterObjectSchemaStmt:
  3568. retval = _copyAlterObjectSchemaStmt(from);
  3569. break;
  3570. case T_AlterOwnerStmt:
  3571. retval = _copyAlterOwnerStmt(from);
  3572. break;
  3573. case T_RuleStmt:
  3574. retval = _copyRuleStmt(from);
  3575. break;
  3576. case T_NotifyStmt:
  3577. retval = _copyNotifyStmt(from);
  3578. break;
  3579. case T_ListenStmt:
  3580. retval = _copyListenStmt(from);
  3581. break;
  3582. case T_UnlistenStmt:
  3583. retval = _copyUnlistenStmt(from);
  3584. break;
  3585. case T_TransactionStmt:
  3586. retval = _copyTransactionStmt(from);
  3587. break;
  3588. case T_CompositeTypeStmt:
  3589. retval = _copyCompositeTypeStmt(from);
  3590. break;
  3591. case T_CreateEnumStmt:
  3592. retval = _copyCreateEnumStmt(from);
  3593. break;
  3594. case T_CreateRangeStmt:
  3595. retval = _copyCreateRangeStmt(from);
  3596. break;
  3597. case T_AlterEnumStmt:
  3598. retval = _copyAlterEnumStmt(from);
  3599. break;
  3600. case T_ViewStmt:
  3601. retval = _copyViewStmt(from);
  3602. break;
  3603. case T_LoadStmt:
  3604. retval = _copyLoadStmt(from);
  3605. break;
  3606. case T_CreateDomainStmt:
  3607. retval = _copyCreateDomainStmt(from);
  3608. break;
  3609. case T_CreateOpClassStmt:
  3610. retval = _copyCreateOpClassStmt(from);
  3611. break;
  3612. case T_CreateOpClassItem:
  3613. retval = _copyCreateOpClassItem(from);
  3614. break;
  3615. case T_CreateOpFamilyStmt:
  3616. retval = _copyCreateOpFamilyStmt(from);
  3617. break;
  3618. case T_AlterOpFamilyStmt:
  3619. retval = _copyAlterOpFamilyStmt(from);
  3620. break;
  3621. case T_CreatedbStmt:
  3622. retval = _copyCreatedbStmt(from);
  3623. break;
  3624. case T_AlterDatabaseStmt:
  3625. retval = _copyAlterDatabaseStmt(from);
  3626. break;
  3627. case T_AlterDatabaseSetStmt:
  3628. retval = _copyAlterDatabaseSetStmt(from);
  3629. break;
  3630. case T_DropdbStmt:
  3631. retval = _copyDropdbStmt(from);
  3632. break;
  3633. case T_VacuumStmt:
  3634. retval = _copyVacuumStmt(from);
  3635. break;
  3636. case T_ExplainStmt:
  3637. retval = _copyExplainStmt(from);
  3638. break;
  3639. case T_CreateTableAsStmt:
  3640. retval = _copyCreateTableAsStmt(from);
  3641. break;
  3642. case T_RefreshMatViewStmt:
  3643. retval = _copyRefreshMatViewStmt(from);
  3644. break;
  3645. case T_ReplicaIdentityStmt:
  3646. retval = _copyReplicaIdentityStmt(from);
  3647. break;
  3648. case T_AlterSystemStmt:
  3649. retval = _copyAlterSystemStmt(from);
  3650. break;
  3651. case T_CreateSeqStmt:
  3652. retval = _copyCreateSeqStmt(from);
  3653. break;
  3654. case T_AlterSeqStmt:
  3655. retval = _copyAlterSeqStmt(from);
  3656. break;
  3657. case T_VariableSetStmt:
  3658. retval = _copyVariableSetStmt(from);
  3659. break;
  3660. case T_VariableShowStmt:
  3661. retval = _copyVariableShowStmt(from);
  3662. break;
  3663. case T_DiscardStmt:
  3664. retval = _copyDiscardStmt(from);
  3665. break;
  3666. case T_CreateTableSpaceStmt:
  3667. retval = _copyCreateTableSpaceStmt(from);
  3668. break;
  3669. case T_DropTableSpaceStmt:
  3670. retval = _copyDropTableSpaceStmt(from);
  3671. break;
  3672. case T_AlterTableSpaceOptionsStmt:
  3673. retval = _copyAlterTableSpaceOptionsStmt(from);
  3674. break;
  3675. case T_AlterTableSpaceMoveStmt:
  3676. retval = _copyAlterTableSpaceMoveStmt(from);
  3677. break;
  3678. case T_CreateExtensionStmt:
  3679. retval = _copyCreateExtensionStmt(from);
  3680. break;
  3681. case T_AlterExtensionStmt:
  3682. retval = _copyAlterExtensionStmt(from);
  3683. break;
  3684. case T_AlterExtensionContentsStmt:
  3685. retval = _copyAlterExtensionContentsStmt(from);
  3686. break;
  3687. case T_CreateFdwStmt:
  3688. retval = _copyCreateFdwStmt(from);
  3689. break;
  3690. case T_AlterFdwStmt:
  3691. retval = _copyAlterFdwStmt(from);
  3692. break;
  3693. case T_CreateForeignServerStmt:
  3694. retval = _copyCreateForeignServerStmt(from);
  3695. break;
  3696. case T_AlterForeignServerStmt:
  3697. retval = _copyAlterForeignServerStmt(from);
  3698. break;
  3699. case T_CreateUserMappingStmt:
  3700. retval = _copyCreateUserMappingStmt(from);
  3701. break;
  3702. case T_AlterUserMappingStmt:
  3703. retval = _copyAlterUserMappingStmt(from);
  3704. break;
  3705. case T_DropUserMappingStmt:
  3706. retval = _copyDropUserMappingStmt(from);
  3707. break;
  3708. case T_CreateForeignTableStmt:
  3709. retval = _copyCreateForeignTableStmt(from);
  3710. break;
  3711. case T_CreateTrigStmt:
  3712. retval = _copyCreateTrigStmt(from);
  3713. break;
  3714. case T_CreateEventTrigStmt:
  3715. retval = _copyCreateEventTrigStmt(from);
  3716. break;
  3717. case T_AlterEventTrigStmt:
  3718. retval = _copyAlterEventTrigStmt(from);
  3719. break;
  3720. case T_CreatePLangStmt:
  3721. retval = _copyCreatePLangStmt(from);
  3722. break;
  3723. case T_CreateRoleStmt:
  3724. retval = _copyCreateRoleStmt(from);
  3725. break;
  3726. case T_AlterRoleStmt:
  3727. retval = _copyAlterRoleStmt(from);
  3728. break;
  3729. case T_AlterRoleSetStmt:
  3730. retval = _copyAlterRoleSetStmt(from);
  3731. break;
  3732. case T_DropRoleStmt:
  3733. retval = _copyDropRoleStmt(from);
  3734. break;
  3735. case T_LockStmt:
  3736. retval = _copyLockStmt(from);
  3737. break;
  3738. case T_ConstraintsSetStmt:
  3739. retval = _copyConstraintsSetStmt(from);
  3740. break;
  3741. case T_ReindexStmt:
  3742. retval = _copyReindexStmt(from);
  3743. break;
  3744. case T_CheckPointStmt:
  3745. retval = (void *) makeNode(CheckPointStmt);
  3746. break;
  3747. case T_CreateSchemaStmt:
  3748. retval = _copyCreateSchemaStmt(from);
  3749. break;
  3750. case T_CreateConversionStmt:
  3751. retval = _copyCreateConversionStmt(from);
  3752. break;
  3753. case T_CreateCastStmt:
  3754. retval = _copyCreateCastStmt(from);
  3755. break;
  3756. case T_PrepareStmt:
  3757. retval = _copyPrepareStmt(from);
  3758. break;
  3759. case T_ExecuteStmt:
  3760. retval = _copyExecuteStmt(from);
  3761. break;
  3762. case T_DeallocateStmt:
  3763. retval = _copyDeallocateStmt(from);
  3764. break;
  3765. case T_DropOwnedStmt:
  3766. retval = _copyDropOwnedStmt(from);
  3767. break;
  3768. case T_ReassignOwnedStmt:
  3769. retval = _copyReassignOwnedStmt(from);
  3770. break;
  3771. case T_AlterTSDictionaryStmt:
  3772. retval = _copyAlterTSDictionaryStmt(from);
  3773. break;
  3774. case T_AlterTSConfigurationStmt:
  3775. retval = _copyAlterTSConfigurationStmt(from);
  3776. break;
  3777. case T_A_Expr:
  3778. retval = _copyAExpr(from);
  3779. break;
  3780. case T_ColumnRef:
  3781. retval = _copyColumnRef(from);
  3782. break;
  3783. case T_ParamRef:
  3784. retval = _copyParamRef(from);
  3785. break;
  3786. case T_A_Const:
  3787. retval = _copyAConst(from);
  3788. break;
  3789. case T_FuncCall:
  3790. retval = _copyFuncCall(from);
  3791. break;
  3792. case T_A_Star:
  3793. retval = _copyAStar(from);
  3794. break;
  3795. case T_A_Indices:
  3796. retval = _copyAIndices(from);
  3797. break;
  3798. case T_A_Indirection:
  3799. retval = _copyA_Indirection(from);
  3800. break;
  3801. case T_A_ArrayExpr:
  3802. retval = _copyA_ArrayExpr(from);
  3803. break;
  3804. case T_ResTarget:
  3805. retval = _copyResTarget(from);
  3806. break;
  3807. case T_TypeCast:
  3808. retval = _copyTypeCast(from);
  3809. break;
  3810. case T_CollateClause:
  3811. retval = _copyCollateClause(from);
  3812. break;
  3813. case T_SortBy:
  3814. retval = _copySortBy(from);
  3815. break;
  3816. case T_WindowDef:
  3817. retval = _copyWindowDef(from);
  3818. break;
  3819. case T_RangeSubselect:
  3820. retval = _copyRangeSubselect(from);
  3821. break;
  3822. case T_RangeFunction:
  3823. retval = _copyRangeFunction(from);
  3824. break;
  3825. case T_TypeName:
  3826. retval = _copyTypeName(from);
  3827. break;
  3828. case T_IndexElem:
  3829. retval = _copyIndexElem(from);
  3830. break;
  3831. case T_ColumnDef:
  3832. retval = _copyColumnDef(from);
  3833. break;
  3834. case T_Constraint:
  3835. retval = _copyConstraint(from);
  3836. break;
  3837. case T_DefElem:
  3838. retval = _copyDefElem(from);
  3839. break;
  3840. case T_LockingClause:
  3841. retval = _copyLockingClause(from);
  3842. break;
  3843. case T_RangeTblEntry:
  3844. retval = _copyRangeTblEntry(from);
  3845. break;
  3846. case T_RangeTblFunction:
  3847. retval = _copyRangeTblFunction(from);
  3848. break;
  3849. case T_WithCheckOption:
  3850. retval = _copyWithCheckOption(from);
  3851. break;
  3852. case T_SortGroupClause:
  3853. retval = _copySortGroupClause(from);
  3854. break;
  3855. case T_WindowClause:
  3856. retval = _copyWindowClause(from);
  3857. break;
  3858. case T_RowMarkClause:
  3859. retval = _copyRowMarkClause(from);
  3860. break;
  3861. case T_WithClause:
  3862. retval = _copyWithClause(from);
  3863. break;
  3864. case T_CommonTableExpr:
  3865. retval = _copyCommonTableExpr(from);
  3866. break;
  3867. case T_PrivGrantee:
  3868. retval = _copyPrivGrantee(from);
  3869. break;
  3870. case T_FuncWithArgs:
  3871. retval = _copyFuncWithArgs(from);
  3872. break;
  3873. case T_AccessPriv:
  3874. retval = _copyAccessPriv(from);
  3875. break;
  3876. case T_XmlSerialize:
  3877. retval = _copyXmlSerialize(from);
  3878. break;
  3879. default:
  3880. elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));
  3881. retval = 0; /* keep compiler quiet */
  3882. break;
  3883. }
  3884. return retval;
  3885. }