PageRenderTime 71ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 1ms

/src/backend/nodes/equalfuncs.c

https://github.com/bbt123/postgres
C | 3113 lines | 2548 code | 421 blank | 144 comment | 54 complexity | 5e716be6d093c5cb1682b90e7e7d0ee6 MD5 | raw file
Possible License(s): AGPL-3.0
  1. /*-------------------------------------------------------------------------
  2. *
  3. * equalfuncs.c
  4. * Equality functions to compare node trees.
  5. *
  6. * NOTE: we currently support comparing all node types found in parse
  7. * trees. We do not support comparing 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 comparing 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. * Currently, in fact, equal() doesn't know how to compare Plan trees
  14. * either. This might need to be fixed someday.
  15. *
  16. * NOTE: it is intentional that parse location fields (in nodes that have
  17. * one) are not compared. This is because we want, for example, a variable
  18. * "x" to be considered equal() to another reference to "x" in the query.
  19. *
  20. *
  21. * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
  22. * Portions Copyright (c) 1994, Regents of the University of California
  23. *
  24. * IDENTIFICATION
  25. * src/backend/nodes/equalfuncs.c
  26. *
  27. *-------------------------------------------------------------------------
  28. */
  29. #include "postgres.h"
  30. #include "nodes/relation.h"
  31. #include "utils/datum.h"
  32. /*
  33. * Macros to simplify comparison of different kinds of fields. Use these
  34. * wherever possible to reduce the chance for silly typos. Note that these
  35. * hard-wire the convention that the local variables in an Equal routine are
  36. * named 'a' and 'b'.
  37. */
  38. /* Compare a simple scalar field (int, float, bool, enum, etc) */
  39. #define COMPARE_SCALAR_FIELD(fldname) \
  40. do { \
  41. if (a->fldname != b->fldname) \
  42. return false; \
  43. } while (0)
  44. /* Compare a field that is a pointer to some kind of Node or Node tree */
  45. #define COMPARE_NODE_FIELD(fldname) \
  46. do { \
  47. if (!equal(a->fldname, b->fldname)) \
  48. return false; \
  49. } while (0)
  50. /* Compare a field that is a pointer to a Bitmapset */
  51. #define COMPARE_BITMAPSET_FIELD(fldname) \
  52. do { \
  53. if (!bms_equal(a->fldname, b->fldname)) \
  54. return false; \
  55. } while (0)
  56. /* Compare a field that is a pointer to a C string, or perhaps NULL */
  57. #define COMPARE_STRING_FIELD(fldname) \
  58. do { \
  59. if (!equalstr(a->fldname, b->fldname)) \
  60. return false; \
  61. } while (0)
  62. /* Macro for comparing string fields that might be NULL */
  63. #define equalstr(a, b) \
  64. (((a) != NULL && (b) != NULL) ? (strcmp(a, b) == 0) : (a) == (b))
  65. /* Compare a field that is a pointer to a simple palloc'd object of size sz */
  66. #define COMPARE_POINTER_FIELD(fldname, sz) \
  67. do { \
  68. if (memcmp(a->fldname, b->fldname, (sz)) != 0) \
  69. return false; \
  70. } while (0)
  71. /* Compare a parse location field (this is a no-op, per note above) */
  72. #define COMPARE_LOCATION_FIELD(fldname) \
  73. ((void) 0)
  74. /* Compare a CoercionForm field (also a no-op, per comment in primnodes.h) */
  75. #define COMPARE_COERCIONFORM_FIELD(fldname) \
  76. ((void) 0)
  77. /*
  78. * Stuff from primnodes.h
  79. */
  80. static bool
  81. _equalAlias(const Alias *a, const Alias *b)
  82. {
  83. COMPARE_STRING_FIELD(aliasname);
  84. COMPARE_NODE_FIELD(colnames);
  85. return true;
  86. }
  87. static bool
  88. _equalRangeVar(const RangeVar *a, const RangeVar *b)
  89. {
  90. COMPARE_STRING_FIELD(catalogname);
  91. COMPARE_STRING_FIELD(schemaname);
  92. COMPARE_STRING_FIELD(relname);
  93. COMPARE_SCALAR_FIELD(inhOpt);
  94. COMPARE_SCALAR_FIELD(relpersistence);
  95. COMPARE_NODE_FIELD(alias);
  96. COMPARE_LOCATION_FIELD(location);
  97. return true;
  98. }
  99. static bool
  100. _equalIntoClause(const IntoClause *a, const IntoClause *b)
  101. {
  102. COMPARE_NODE_FIELD(rel);
  103. COMPARE_NODE_FIELD(colNames);
  104. COMPARE_NODE_FIELD(options);
  105. COMPARE_SCALAR_FIELD(onCommit);
  106. COMPARE_STRING_FIELD(tableSpaceName);
  107. COMPARE_NODE_FIELD(viewQuery);
  108. COMPARE_SCALAR_FIELD(skipData);
  109. return true;
  110. }
  111. /*
  112. * We don't need an _equalExpr because Expr is an abstract supertype which
  113. * should never actually get instantiated. Also, since it has no common
  114. * fields except NodeTag, there's no need for a helper routine to factor
  115. * out comparing the common fields...
  116. */
  117. static bool
  118. _equalVar(const Var *a, const Var *b)
  119. {
  120. COMPARE_SCALAR_FIELD(varno);
  121. COMPARE_SCALAR_FIELD(varattno);
  122. COMPARE_SCALAR_FIELD(vartype);
  123. COMPARE_SCALAR_FIELD(vartypmod);
  124. COMPARE_SCALAR_FIELD(varcollid);
  125. COMPARE_SCALAR_FIELD(varlevelsup);
  126. COMPARE_SCALAR_FIELD(varnoold);
  127. COMPARE_SCALAR_FIELD(varoattno);
  128. COMPARE_LOCATION_FIELD(location);
  129. return true;
  130. }
  131. static bool
  132. _equalConst(const Const *a, const Const *b)
  133. {
  134. COMPARE_SCALAR_FIELD(consttype);
  135. COMPARE_SCALAR_FIELD(consttypmod);
  136. COMPARE_SCALAR_FIELD(constcollid);
  137. COMPARE_SCALAR_FIELD(constlen);
  138. COMPARE_SCALAR_FIELD(constisnull);
  139. COMPARE_SCALAR_FIELD(constbyval);
  140. COMPARE_LOCATION_FIELD(location);
  141. /*
  142. * We treat all NULL constants of the same type as equal. Someday this
  143. * might need to change? But datumIsEqual doesn't work on nulls, so...
  144. */
  145. if (a->constisnull)
  146. return true;
  147. return datumIsEqual(a->constvalue, b->constvalue,
  148. a->constbyval, a->constlen);
  149. }
  150. static bool
  151. _equalParam(const Param *a, const Param *b)
  152. {
  153. COMPARE_SCALAR_FIELD(paramkind);
  154. COMPARE_SCALAR_FIELD(paramid);
  155. COMPARE_SCALAR_FIELD(paramtype);
  156. COMPARE_SCALAR_FIELD(paramtypmod);
  157. COMPARE_SCALAR_FIELD(paramcollid);
  158. COMPARE_LOCATION_FIELD(location);
  159. return true;
  160. }
  161. static bool
  162. _equalAggref(const Aggref *a, const Aggref *b)
  163. {
  164. COMPARE_SCALAR_FIELD(aggfnoid);
  165. COMPARE_SCALAR_FIELD(aggtype);
  166. COMPARE_SCALAR_FIELD(aggcollid);
  167. COMPARE_SCALAR_FIELD(inputcollid);
  168. COMPARE_NODE_FIELD(aggdirectargs);
  169. COMPARE_NODE_FIELD(args);
  170. COMPARE_NODE_FIELD(aggorder);
  171. COMPARE_NODE_FIELD(aggdistinct);
  172. COMPARE_NODE_FIELD(aggfilter);
  173. COMPARE_SCALAR_FIELD(aggstar);
  174. COMPARE_SCALAR_FIELD(aggvariadic);
  175. COMPARE_SCALAR_FIELD(aggkind);
  176. COMPARE_SCALAR_FIELD(agglevelsup);
  177. COMPARE_LOCATION_FIELD(location);
  178. return true;
  179. }
  180. static bool
  181. _equalWindowFunc(const WindowFunc *a, const WindowFunc *b)
  182. {
  183. COMPARE_SCALAR_FIELD(winfnoid);
  184. COMPARE_SCALAR_FIELD(wintype);
  185. COMPARE_SCALAR_FIELD(wincollid);
  186. COMPARE_SCALAR_FIELD(inputcollid);
  187. COMPARE_NODE_FIELD(args);
  188. COMPARE_NODE_FIELD(aggfilter);
  189. COMPARE_SCALAR_FIELD(winref);
  190. COMPARE_SCALAR_FIELD(winstar);
  191. COMPARE_SCALAR_FIELD(winagg);
  192. COMPARE_LOCATION_FIELD(location);
  193. return true;
  194. }
  195. static bool
  196. _equalArrayRef(const ArrayRef *a, const ArrayRef *b)
  197. {
  198. COMPARE_SCALAR_FIELD(refarraytype);
  199. COMPARE_SCALAR_FIELD(refelemtype);
  200. COMPARE_SCALAR_FIELD(reftypmod);
  201. COMPARE_SCALAR_FIELD(refcollid);
  202. COMPARE_NODE_FIELD(refupperindexpr);
  203. COMPARE_NODE_FIELD(reflowerindexpr);
  204. COMPARE_NODE_FIELD(refexpr);
  205. COMPARE_NODE_FIELD(refassgnexpr);
  206. return true;
  207. }
  208. static bool
  209. _equalFuncExpr(const FuncExpr *a, const FuncExpr *b)
  210. {
  211. COMPARE_SCALAR_FIELD(funcid);
  212. COMPARE_SCALAR_FIELD(funcresulttype);
  213. COMPARE_SCALAR_FIELD(funcretset);
  214. COMPARE_SCALAR_FIELD(funcvariadic);
  215. COMPARE_COERCIONFORM_FIELD(funcformat);
  216. COMPARE_SCALAR_FIELD(funccollid);
  217. COMPARE_SCALAR_FIELD(inputcollid);
  218. COMPARE_NODE_FIELD(args);
  219. COMPARE_LOCATION_FIELD(location);
  220. return true;
  221. }
  222. static bool
  223. _equalNamedArgExpr(const NamedArgExpr *a, const NamedArgExpr *b)
  224. {
  225. COMPARE_NODE_FIELD(arg);
  226. COMPARE_STRING_FIELD(name);
  227. COMPARE_SCALAR_FIELD(argnumber);
  228. COMPARE_LOCATION_FIELD(location);
  229. return true;
  230. }
  231. static bool
  232. _equalOpExpr(const OpExpr *a, const OpExpr *b)
  233. {
  234. COMPARE_SCALAR_FIELD(opno);
  235. /*
  236. * Special-case opfuncid: it is allowable for it to differ if one node
  237. * contains zero and the other doesn't. This just means that the one node
  238. * isn't as far along in the parse/plan pipeline and hasn't had the
  239. * opfuncid cache filled yet.
  240. */
  241. if (a->opfuncid != b->opfuncid &&
  242. a->opfuncid != 0 &&
  243. b->opfuncid != 0)
  244. return false;
  245. COMPARE_SCALAR_FIELD(opresulttype);
  246. COMPARE_SCALAR_FIELD(opretset);
  247. COMPARE_SCALAR_FIELD(opcollid);
  248. COMPARE_SCALAR_FIELD(inputcollid);
  249. COMPARE_NODE_FIELD(args);
  250. COMPARE_LOCATION_FIELD(location);
  251. return true;
  252. }
  253. static bool
  254. _equalDistinctExpr(const DistinctExpr *a, const DistinctExpr *b)
  255. {
  256. COMPARE_SCALAR_FIELD(opno);
  257. /*
  258. * Special-case opfuncid: it is allowable for it to differ if one node
  259. * contains zero and the other doesn't. This just means that the one node
  260. * isn't as far along in the parse/plan pipeline and hasn't had the
  261. * opfuncid cache filled yet.
  262. */
  263. if (a->opfuncid != b->opfuncid &&
  264. a->opfuncid != 0 &&
  265. b->opfuncid != 0)
  266. return false;
  267. COMPARE_SCALAR_FIELD(opresulttype);
  268. COMPARE_SCALAR_FIELD(opretset);
  269. COMPARE_SCALAR_FIELD(opcollid);
  270. COMPARE_SCALAR_FIELD(inputcollid);
  271. COMPARE_NODE_FIELD(args);
  272. COMPARE_LOCATION_FIELD(location);
  273. return true;
  274. }
  275. static bool
  276. _equalNullIfExpr(const NullIfExpr *a, const NullIfExpr *b)
  277. {
  278. COMPARE_SCALAR_FIELD(opno);
  279. /*
  280. * Special-case opfuncid: it is allowable for it to differ if one node
  281. * contains zero and the other doesn't. This just means that the one node
  282. * isn't as far along in the parse/plan pipeline and hasn't had the
  283. * opfuncid cache filled yet.
  284. */
  285. if (a->opfuncid != b->opfuncid &&
  286. a->opfuncid != 0 &&
  287. b->opfuncid != 0)
  288. return false;
  289. COMPARE_SCALAR_FIELD(opresulttype);
  290. COMPARE_SCALAR_FIELD(opretset);
  291. COMPARE_SCALAR_FIELD(opcollid);
  292. COMPARE_SCALAR_FIELD(inputcollid);
  293. COMPARE_NODE_FIELD(args);
  294. COMPARE_LOCATION_FIELD(location);
  295. return true;
  296. }
  297. static bool
  298. _equalScalarArrayOpExpr(const ScalarArrayOpExpr *a, const ScalarArrayOpExpr *b)
  299. {
  300. COMPARE_SCALAR_FIELD(opno);
  301. /*
  302. * Special-case opfuncid: it is allowable for it to differ if one node
  303. * contains zero and the other doesn't. This just means that the one node
  304. * isn't as far along in the parse/plan pipeline and hasn't had the
  305. * opfuncid cache filled yet.
  306. */
  307. if (a->opfuncid != b->opfuncid &&
  308. a->opfuncid != 0 &&
  309. b->opfuncid != 0)
  310. return false;
  311. COMPARE_SCALAR_FIELD(useOr);
  312. COMPARE_SCALAR_FIELD(inputcollid);
  313. COMPARE_NODE_FIELD(args);
  314. COMPARE_LOCATION_FIELD(location);
  315. return true;
  316. }
  317. static bool
  318. _equalBoolExpr(const BoolExpr *a, const BoolExpr *b)
  319. {
  320. COMPARE_SCALAR_FIELD(boolop);
  321. COMPARE_NODE_FIELD(args);
  322. COMPARE_LOCATION_FIELD(location);
  323. return true;
  324. }
  325. static bool
  326. _equalSubLink(const SubLink *a, const SubLink *b)
  327. {
  328. COMPARE_SCALAR_FIELD(subLinkType);
  329. COMPARE_NODE_FIELD(testexpr);
  330. COMPARE_NODE_FIELD(operName);
  331. COMPARE_NODE_FIELD(subselect);
  332. COMPARE_LOCATION_FIELD(location);
  333. return true;
  334. }
  335. static bool
  336. _equalSubPlan(const SubPlan *a, const SubPlan *b)
  337. {
  338. COMPARE_SCALAR_FIELD(subLinkType);
  339. COMPARE_NODE_FIELD(testexpr);
  340. COMPARE_NODE_FIELD(paramIds);
  341. COMPARE_SCALAR_FIELD(plan_id);
  342. COMPARE_STRING_FIELD(plan_name);
  343. COMPARE_SCALAR_FIELD(firstColType);
  344. COMPARE_SCALAR_FIELD(firstColTypmod);
  345. COMPARE_SCALAR_FIELD(firstColCollation);
  346. COMPARE_SCALAR_FIELD(useHashTable);
  347. COMPARE_SCALAR_FIELD(unknownEqFalse);
  348. COMPARE_NODE_FIELD(setParam);
  349. COMPARE_NODE_FIELD(parParam);
  350. COMPARE_NODE_FIELD(args);
  351. COMPARE_SCALAR_FIELD(startup_cost);
  352. COMPARE_SCALAR_FIELD(per_call_cost);
  353. return true;
  354. }
  355. static bool
  356. _equalAlternativeSubPlan(const AlternativeSubPlan *a, const AlternativeSubPlan *b)
  357. {
  358. COMPARE_NODE_FIELD(subplans);
  359. return true;
  360. }
  361. static bool
  362. _equalFieldSelect(const FieldSelect *a, const FieldSelect *b)
  363. {
  364. COMPARE_NODE_FIELD(arg);
  365. COMPARE_SCALAR_FIELD(fieldnum);
  366. COMPARE_SCALAR_FIELD(resulttype);
  367. COMPARE_SCALAR_FIELD(resulttypmod);
  368. COMPARE_SCALAR_FIELD(resultcollid);
  369. return true;
  370. }
  371. static bool
  372. _equalFieldStore(const FieldStore *a, const FieldStore *b)
  373. {
  374. COMPARE_NODE_FIELD(arg);
  375. COMPARE_NODE_FIELD(newvals);
  376. COMPARE_NODE_FIELD(fieldnums);
  377. COMPARE_SCALAR_FIELD(resulttype);
  378. return true;
  379. }
  380. static bool
  381. _equalRelabelType(const RelabelType *a, const RelabelType *b)
  382. {
  383. COMPARE_NODE_FIELD(arg);
  384. COMPARE_SCALAR_FIELD(resulttype);
  385. COMPARE_SCALAR_FIELD(resulttypmod);
  386. COMPARE_SCALAR_FIELD(resultcollid);
  387. COMPARE_COERCIONFORM_FIELD(relabelformat);
  388. COMPARE_LOCATION_FIELD(location);
  389. return true;
  390. }
  391. static bool
  392. _equalCoerceViaIO(const CoerceViaIO *a, const CoerceViaIO *b)
  393. {
  394. COMPARE_NODE_FIELD(arg);
  395. COMPARE_SCALAR_FIELD(resulttype);
  396. COMPARE_SCALAR_FIELD(resultcollid);
  397. COMPARE_COERCIONFORM_FIELD(coerceformat);
  398. COMPARE_LOCATION_FIELD(location);
  399. return true;
  400. }
  401. static bool
  402. _equalArrayCoerceExpr(const ArrayCoerceExpr *a, const ArrayCoerceExpr *b)
  403. {
  404. COMPARE_NODE_FIELD(arg);
  405. COMPARE_SCALAR_FIELD(elemfuncid);
  406. COMPARE_SCALAR_FIELD(resulttype);
  407. COMPARE_SCALAR_FIELD(resulttypmod);
  408. COMPARE_SCALAR_FIELD(resultcollid);
  409. COMPARE_SCALAR_FIELD(isExplicit);
  410. COMPARE_COERCIONFORM_FIELD(coerceformat);
  411. COMPARE_LOCATION_FIELD(location);
  412. return true;
  413. }
  414. static bool
  415. _equalConvertRowtypeExpr(const ConvertRowtypeExpr *a, const ConvertRowtypeExpr *b)
  416. {
  417. COMPARE_NODE_FIELD(arg);
  418. COMPARE_SCALAR_FIELD(resulttype);
  419. COMPARE_COERCIONFORM_FIELD(convertformat);
  420. COMPARE_LOCATION_FIELD(location);
  421. return true;
  422. }
  423. static bool
  424. _equalCollateExpr(const CollateExpr *a, const CollateExpr *b)
  425. {
  426. COMPARE_NODE_FIELD(arg);
  427. COMPARE_SCALAR_FIELD(collOid);
  428. COMPARE_LOCATION_FIELD(location);
  429. return true;
  430. }
  431. static bool
  432. _equalCaseExpr(const CaseExpr *a, const CaseExpr *b)
  433. {
  434. COMPARE_SCALAR_FIELD(casetype);
  435. COMPARE_SCALAR_FIELD(casecollid);
  436. COMPARE_NODE_FIELD(arg);
  437. COMPARE_NODE_FIELD(args);
  438. COMPARE_NODE_FIELD(defresult);
  439. COMPARE_LOCATION_FIELD(location);
  440. return true;
  441. }
  442. static bool
  443. _equalCaseWhen(const CaseWhen *a, const CaseWhen *b)
  444. {
  445. COMPARE_NODE_FIELD(expr);
  446. COMPARE_NODE_FIELD(result);
  447. COMPARE_LOCATION_FIELD(location);
  448. return true;
  449. }
  450. static bool
  451. _equalCaseTestExpr(const CaseTestExpr *a, const CaseTestExpr *b)
  452. {
  453. COMPARE_SCALAR_FIELD(typeId);
  454. COMPARE_SCALAR_FIELD(typeMod);
  455. COMPARE_SCALAR_FIELD(collation);
  456. return true;
  457. }
  458. static bool
  459. _equalArrayExpr(const ArrayExpr *a, const ArrayExpr *b)
  460. {
  461. COMPARE_SCALAR_FIELD(array_typeid);
  462. COMPARE_SCALAR_FIELD(array_collid);
  463. COMPARE_SCALAR_FIELD(element_typeid);
  464. COMPARE_NODE_FIELD(elements);
  465. COMPARE_SCALAR_FIELD(multidims);
  466. COMPARE_LOCATION_FIELD(location);
  467. return true;
  468. }
  469. static bool
  470. _equalRowExpr(const RowExpr *a, const RowExpr *b)
  471. {
  472. COMPARE_NODE_FIELD(args);
  473. COMPARE_SCALAR_FIELD(row_typeid);
  474. COMPARE_COERCIONFORM_FIELD(row_format);
  475. COMPARE_NODE_FIELD(colnames);
  476. COMPARE_LOCATION_FIELD(location);
  477. return true;
  478. }
  479. static bool
  480. _equalRowCompareExpr(const RowCompareExpr *a, const RowCompareExpr *b)
  481. {
  482. COMPARE_SCALAR_FIELD(rctype);
  483. COMPARE_NODE_FIELD(opnos);
  484. COMPARE_NODE_FIELD(opfamilies);
  485. COMPARE_NODE_FIELD(inputcollids);
  486. COMPARE_NODE_FIELD(largs);
  487. COMPARE_NODE_FIELD(rargs);
  488. return true;
  489. }
  490. static bool
  491. _equalCoalesceExpr(const CoalesceExpr *a, const CoalesceExpr *b)
  492. {
  493. COMPARE_SCALAR_FIELD(coalescetype);
  494. COMPARE_SCALAR_FIELD(coalescecollid);
  495. COMPARE_NODE_FIELD(args);
  496. COMPARE_LOCATION_FIELD(location);
  497. return true;
  498. }
  499. static bool
  500. _equalMinMaxExpr(const MinMaxExpr *a, const MinMaxExpr *b)
  501. {
  502. COMPARE_SCALAR_FIELD(minmaxtype);
  503. COMPARE_SCALAR_FIELD(minmaxcollid);
  504. COMPARE_SCALAR_FIELD(inputcollid);
  505. COMPARE_SCALAR_FIELD(op);
  506. COMPARE_NODE_FIELD(args);
  507. COMPARE_LOCATION_FIELD(location);
  508. return true;
  509. }
  510. static bool
  511. _equalXmlExpr(const XmlExpr *a, const XmlExpr *b)
  512. {
  513. COMPARE_SCALAR_FIELD(op);
  514. COMPARE_STRING_FIELD(name);
  515. COMPARE_NODE_FIELD(named_args);
  516. COMPARE_NODE_FIELD(arg_names);
  517. COMPARE_NODE_FIELD(args);
  518. COMPARE_SCALAR_FIELD(xmloption);
  519. COMPARE_SCALAR_FIELD(type);
  520. COMPARE_SCALAR_FIELD(typmod);
  521. COMPARE_LOCATION_FIELD(location);
  522. return true;
  523. }
  524. static bool
  525. _equalNullTest(const NullTest *a, const NullTest *b)
  526. {
  527. COMPARE_NODE_FIELD(arg);
  528. COMPARE_SCALAR_FIELD(nulltesttype);
  529. COMPARE_SCALAR_FIELD(argisrow);
  530. return true;
  531. }
  532. static bool
  533. _equalBooleanTest(const BooleanTest *a, const BooleanTest *b)
  534. {
  535. COMPARE_NODE_FIELD(arg);
  536. COMPARE_SCALAR_FIELD(booltesttype);
  537. return true;
  538. }
  539. static bool
  540. _equalCoerceToDomain(const CoerceToDomain *a, const CoerceToDomain *b)
  541. {
  542. COMPARE_NODE_FIELD(arg);
  543. COMPARE_SCALAR_FIELD(resulttype);
  544. COMPARE_SCALAR_FIELD(resulttypmod);
  545. COMPARE_SCALAR_FIELD(resultcollid);
  546. COMPARE_COERCIONFORM_FIELD(coercionformat);
  547. COMPARE_LOCATION_FIELD(location);
  548. return true;
  549. }
  550. static bool
  551. _equalCoerceToDomainValue(const CoerceToDomainValue *a, const CoerceToDomainValue *b)
  552. {
  553. COMPARE_SCALAR_FIELD(typeId);
  554. COMPARE_SCALAR_FIELD(typeMod);
  555. COMPARE_SCALAR_FIELD(collation);
  556. COMPARE_LOCATION_FIELD(location);
  557. return true;
  558. }
  559. static bool
  560. _equalSetToDefault(const SetToDefault *a, const SetToDefault *b)
  561. {
  562. COMPARE_SCALAR_FIELD(typeId);
  563. COMPARE_SCALAR_FIELD(typeMod);
  564. COMPARE_SCALAR_FIELD(collation);
  565. COMPARE_LOCATION_FIELD(location);
  566. return true;
  567. }
  568. static bool
  569. _equalCurrentOfExpr(const CurrentOfExpr *a, const CurrentOfExpr *b)
  570. {
  571. COMPARE_SCALAR_FIELD(cvarno);
  572. COMPARE_STRING_FIELD(cursor_name);
  573. COMPARE_SCALAR_FIELD(cursor_param);
  574. return true;
  575. }
  576. static bool
  577. _equalTargetEntry(const TargetEntry *a, const TargetEntry *b)
  578. {
  579. COMPARE_NODE_FIELD(expr);
  580. COMPARE_SCALAR_FIELD(resno);
  581. COMPARE_STRING_FIELD(resname);
  582. COMPARE_SCALAR_FIELD(ressortgroupref);
  583. COMPARE_SCALAR_FIELD(resorigtbl);
  584. COMPARE_SCALAR_FIELD(resorigcol);
  585. COMPARE_SCALAR_FIELD(resjunk);
  586. return true;
  587. }
  588. static bool
  589. _equalRangeTblRef(const RangeTblRef *a, const RangeTblRef *b)
  590. {
  591. COMPARE_SCALAR_FIELD(rtindex);
  592. return true;
  593. }
  594. static bool
  595. _equalJoinExpr(const JoinExpr *a, const JoinExpr *b)
  596. {
  597. COMPARE_SCALAR_FIELD(jointype);
  598. COMPARE_SCALAR_FIELD(isNatural);
  599. COMPARE_NODE_FIELD(larg);
  600. COMPARE_NODE_FIELD(rarg);
  601. COMPARE_NODE_FIELD(usingClause);
  602. COMPARE_NODE_FIELD(quals);
  603. COMPARE_NODE_FIELD(alias);
  604. COMPARE_SCALAR_FIELD(rtindex);
  605. return true;
  606. }
  607. static bool
  608. _equalFromExpr(const FromExpr *a, const FromExpr *b)
  609. {
  610. COMPARE_NODE_FIELD(fromlist);
  611. COMPARE_NODE_FIELD(quals);
  612. return true;
  613. }
  614. /*
  615. * Stuff from relation.h
  616. */
  617. static bool
  618. _equalPathKey(const PathKey *a, const PathKey *b)
  619. {
  620. /* We assume pointer equality is sufficient to compare the eclasses */
  621. COMPARE_SCALAR_FIELD(pk_eclass);
  622. COMPARE_SCALAR_FIELD(pk_opfamily);
  623. COMPARE_SCALAR_FIELD(pk_strategy);
  624. COMPARE_SCALAR_FIELD(pk_nulls_first);
  625. return true;
  626. }
  627. static bool
  628. _equalRestrictInfo(const RestrictInfo *a, const RestrictInfo *b)
  629. {
  630. COMPARE_NODE_FIELD(clause);
  631. COMPARE_SCALAR_FIELD(is_pushed_down);
  632. COMPARE_SCALAR_FIELD(outerjoin_delayed);
  633. COMPARE_BITMAPSET_FIELD(required_relids);
  634. COMPARE_BITMAPSET_FIELD(outer_relids);
  635. COMPARE_BITMAPSET_FIELD(nullable_relids);
  636. /*
  637. * We ignore all the remaining fields, since they may not be set yet, and
  638. * should be derivable from the clause anyway.
  639. */
  640. return true;
  641. }
  642. static bool
  643. _equalPlaceHolderVar(const PlaceHolderVar *a, const PlaceHolderVar *b)
  644. {
  645. /*
  646. * We intentionally do not compare phexpr. Two PlaceHolderVars with the
  647. * same ID and levelsup should be considered equal even if the contained
  648. * expressions have managed to mutate to different states. This will
  649. * happen during final plan construction when there are nested PHVs, since
  650. * the inner PHV will get replaced by a Param in some copies of the outer
  651. * PHV. Another way in which it can happen is that initplan sublinks
  652. * could get replaced by differently-numbered Params when sublink folding
  653. * is done. (The end result of such a situation would be some
  654. * unreferenced initplans, which is annoying but not really a problem.) On
  655. * the same reasoning, there is no need to examine phrels.
  656. *
  657. * COMPARE_NODE_FIELD(phexpr);
  658. *
  659. * COMPARE_BITMAPSET_FIELD(phrels);
  660. */
  661. COMPARE_SCALAR_FIELD(phid);
  662. COMPARE_SCALAR_FIELD(phlevelsup);
  663. return true;
  664. }
  665. static bool
  666. _equalSpecialJoinInfo(const SpecialJoinInfo *a, const SpecialJoinInfo *b)
  667. {
  668. COMPARE_BITMAPSET_FIELD(min_lefthand);
  669. COMPARE_BITMAPSET_FIELD(min_righthand);
  670. COMPARE_BITMAPSET_FIELD(syn_lefthand);
  671. COMPARE_BITMAPSET_FIELD(syn_righthand);
  672. COMPARE_SCALAR_FIELD(jointype);
  673. COMPARE_SCALAR_FIELD(lhs_strict);
  674. COMPARE_SCALAR_FIELD(delay_upper_joins);
  675. COMPARE_NODE_FIELD(join_quals);
  676. return true;
  677. }
  678. static bool
  679. _equalLateralJoinInfo(const LateralJoinInfo *a, const LateralJoinInfo *b)
  680. {
  681. COMPARE_BITMAPSET_FIELD(lateral_lhs);
  682. COMPARE_BITMAPSET_FIELD(lateral_rhs);
  683. return true;
  684. }
  685. static bool
  686. _equalAppendRelInfo(const AppendRelInfo *a, const AppendRelInfo *b)
  687. {
  688. COMPARE_SCALAR_FIELD(parent_relid);
  689. COMPARE_SCALAR_FIELD(child_relid);
  690. COMPARE_SCALAR_FIELD(parent_reltype);
  691. COMPARE_SCALAR_FIELD(child_reltype);
  692. COMPARE_NODE_FIELD(translated_vars);
  693. COMPARE_SCALAR_FIELD(parent_reloid);
  694. return true;
  695. }
  696. static bool
  697. _equalPlaceHolderInfo(const PlaceHolderInfo *a, const PlaceHolderInfo *b)
  698. {
  699. COMPARE_SCALAR_FIELD(phid);
  700. COMPARE_NODE_FIELD(ph_var); /* should be redundant */
  701. COMPARE_BITMAPSET_FIELD(ph_eval_at);
  702. COMPARE_BITMAPSET_FIELD(ph_lateral);
  703. COMPARE_BITMAPSET_FIELD(ph_needed);
  704. COMPARE_SCALAR_FIELD(ph_width);
  705. return true;
  706. }
  707. /*
  708. * Stuff from parsenodes.h
  709. */
  710. static bool
  711. _equalQuery(const Query *a, const Query *b)
  712. {
  713. COMPARE_SCALAR_FIELD(commandType);
  714. COMPARE_SCALAR_FIELD(querySource);
  715. /* we intentionally ignore queryId, since it might not be set */
  716. COMPARE_SCALAR_FIELD(canSetTag);
  717. COMPARE_NODE_FIELD(utilityStmt);
  718. COMPARE_SCALAR_FIELD(resultRelation);
  719. COMPARE_SCALAR_FIELD(hasAggs);
  720. COMPARE_SCALAR_FIELD(hasWindowFuncs);
  721. COMPARE_SCALAR_FIELD(hasSubLinks);
  722. COMPARE_SCALAR_FIELD(hasDistinctOn);
  723. COMPARE_SCALAR_FIELD(hasRecursive);
  724. COMPARE_SCALAR_FIELD(hasModifyingCTE);
  725. COMPARE_SCALAR_FIELD(hasForUpdate);
  726. COMPARE_NODE_FIELD(cteList);
  727. COMPARE_NODE_FIELD(rtable);
  728. COMPARE_NODE_FIELD(jointree);
  729. COMPARE_NODE_FIELD(targetList);
  730. COMPARE_NODE_FIELD(withCheckOptions);
  731. COMPARE_NODE_FIELD(returningList);
  732. COMPARE_NODE_FIELD(groupClause);
  733. COMPARE_NODE_FIELD(havingQual);
  734. COMPARE_NODE_FIELD(windowClause);
  735. COMPARE_NODE_FIELD(distinctClause);
  736. COMPARE_NODE_FIELD(sortClause);
  737. COMPARE_NODE_FIELD(limitOffset);
  738. COMPARE_NODE_FIELD(limitCount);
  739. COMPARE_NODE_FIELD(rowMarks);
  740. COMPARE_NODE_FIELD(setOperations);
  741. COMPARE_NODE_FIELD(constraintDeps);
  742. return true;
  743. }
  744. static bool
  745. _equalInsertStmt(const InsertStmt *a, const InsertStmt *b)
  746. {
  747. COMPARE_NODE_FIELD(relation);
  748. COMPARE_NODE_FIELD(cols);
  749. COMPARE_NODE_FIELD(selectStmt);
  750. COMPARE_NODE_FIELD(returningList);
  751. COMPARE_NODE_FIELD(withClause);
  752. return true;
  753. }
  754. static bool
  755. _equalDeleteStmt(const DeleteStmt *a, const DeleteStmt *b)
  756. {
  757. COMPARE_NODE_FIELD(relation);
  758. COMPARE_NODE_FIELD(usingClause);
  759. COMPARE_NODE_FIELD(whereClause);
  760. COMPARE_NODE_FIELD(returningList);
  761. COMPARE_NODE_FIELD(withClause);
  762. return true;
  763. }
  764. static bool
  765. _equalUpdateStmt(const UpdateStmt *a, const UpdateStmt *b)
  766. {
  767. COMPARE_NODE_FIELD(relation);
  768. COMPARE_NODE_FIELD(targetList);
  769. COMPARE_NODE_FIELD(whereClause);
  770. COMPARE_NODE_FIELD(fromClause);
  771. COMPARE_NODE_FIELD(returningList);
  772. COMPARE_NODE_FIELD(withClause);
  773. return true;
  774. }
  775. static bool
  776. _equalSelectStmt(const SelectStmt *a, const SelectStmt *b)
  777. {
  778. COMPARE_NODE_FIELD(distinctClause);
  779. COMPARE_NODE_FIELD(intoClause);
  780. COMPARE_NODE_FIELD(targetList);
  781. COMPARE_NODE_FIELD(fromClause);
  782. COMPARE_NODE_FIELD(whereClause);
  783. COMPARE_NODE_FIELD(groupClause);
  784. COMPARE_NODE_FIELD(havingClause);
  785. COMPARE_NODE_FIELD(windowClause);
  786. COMPARE_NODE_FIELD(valuesLists);
  787. COMPARE_NODE_FIELD(sortClause);
  788. COMPARE_NODE_FIELD(limitOffset);
  789. COMPARE_NODE_FIELD(limitCount);
  790. COMPARE_NODE_FIELD(lockingClause);
  791. COMPARE_NODE_FIELD(withClause);
  792. COMPARE_SCALAR_FIELD(op);
  793. COMPARE_SCALAR_FIELD(all);
  794. COMPARE_NODE_FIELD(larg);
  795. COMPARE_NODE_FIELD(rarg);
  796. return true;
  797. }
  798. static bool
  799. _equalSetOperationStmt(const SetOperationStmt *a, const SetOperationStmt *b)
  800. {
  801. COMPARE_SCALAR_FIELD(op);
  802. COMPARE_SCALAR_FIELD(all);
  803. COMPARE_NODE_FIELD(larg);
  804. COMPARE_NODE_FIELD(rarg);
  805. COMPARE_NODE_FIELD(colTypes);
  806. COMPARE_NODE_FIELD(colTypmods);
  807. COMPARE_NODE_FIELD(colCollations);
  808. COMPARE_NODE_FIELD(groupClauses);
  809. return true;
  810. }
  811. static bool
  812. _equalAlterTableStmt(const AlterTableStmt *a, const AlterTableStmt *b)
  813. {
  814. COMPARE_NODE_FIELD(relation);
  815. COMPARE_NODE_FIELD(cmds);
  816. COMPARE_SCALAR_FIELD(relkind);
  817. COMPARE_SCALAR_FIELD(missing_ok);
  818. return true;
  819. }
  820. static bool
  821. _equalAlterTableCmd(const AlterTableCmd *a, const AlterTableCmd *b)
  822. {
  823. COMPARE_SCALAR_FIELD(subtype);
  824. COMPARE_STRING_FIELD(name);
  825. COMPARE_NODE_FIELD(def);
  826. COMPARE_SCALAR_FIELD(behavior);
  827. COMPARE_SCALAR_FIELD(missing_ok);
  828. return true;
  829. }
  830. static bool
  831. _equalAlterDomainStmt(const AlterDomainStmt *a, const AlterDomainStmt *b)
  832. {
  833. COMPARE_SCALAR_FIELD(subtype);
  834. COMPARE_NODE_FIELD(typeName);
  835. COMPARE_STRING_FIELD(name);
  836. COMPARE_NODE_FIELD(def);
  837. COMPARE_SCALAR_FIELD(behavior);
  838. COMPARE_SCALAR_FIELD(missing_ok);
  839. return true;
  840. }
  841. static bool
  842. _equalGrantStmt(const GrantStmt *a, const GrantStmt *b)
  843. {
  844. COMPARE_SCALAR_FIELD(is_grant);
  845. COMPARE_SCALAR_FIELD(targtype);
  846. COMPARE_SCALAR_FIELD(objtype);
  847. COMPARE_NODE_FIELD(objects);
  848. COMPARE_NODE_FIELD(privileges);
  849. COMPARE_NODE_FIELD(grantees);
  850. COMPARE_SCALAR_FIELD(grant_option);
  851. COMPARE_SCALAR_FIELD(behavior);
  852. return true;
  853. }
  854. static bool
  855. _equalPrivGrantee(const PrivGrantee *a, const PrivGrantee *b)
  856. {
  857. COMPARE_STRING_FIELD(rolname);
  858. return true;
  859. }
  860. static bool
  861. _equalFuncWithArgs(const FuncWithArgs *a, const FuncWithArgs *b)
  862. {
  863. COMPARE_NODE_FIELD(funcname);
  864. COMPARE_NODE_FIELD(funcargs);
  865. return true;
  866. }
  867. static bool
  868. _equalAccessPriv(const AccessPriv *a, const AccessPriv *b)
  869. {
  870. COMPARE_STRING_FIELD(priv_name);
  871. COMPARE_NODE_FIELD(cols);
  872. return true;
  873. }
  874. static bool
  875. _equalGrantRoleStmt(const GrantRoleStmt *a, const GrantRoleStmt *b)
  876. {
  877. COMPARE_NODE_FIELD(granted_roles);
  878. COMPARE_NODE_FIELD(grantee_roles);
  879. COMPARE_SCALAR_FIELD(is_grant);
  880. COMPARE_SCALAR_FIELD(admin_opt);
  881. COMPARE_STRING_FIELD(grantor);
  882. COMPARE_SCALAR_FIELD(behavior);
  883. return true;
  884. }
  885. static bool
  886. _equalAlterDefaultPrivilegesStmt(const AlterDefaultPrivilegesStmt *a, const AlterDefaultPrivilegesStmt *b)
  887. {
  888. COMPARE_NODE_FIELD(options);
  889. COMPARE_NODE_FIELD(action);
  890. return true;
  891. }
  892. static bool
  893. _equalDeclareCursorStmt(const DeclareCursorStmt *a, const DeclareCursorStmt *b)
  894. {
  895. COMPARE_STRING_FIELD(portalname);
  896. COMPARE_SCALAR_FIELD(options);
  897. COMPARE_NODE_FIELD(query);
  898. return true;
  899. }
  900. static bool
  901. _equalClosePortalStmt(const ClosePortalStmt *a, const ClosePortalStmt *b)
  902. {
  903. COMPARE_STRING_FIELD(portalname);
  904. return true;
  905. }
  906. static bool
  907. _equalClusterStmt(const ClusterStmt *a, const ClusterStmt *b)
  908. {
  909. COMPARE_NODE_FIELD(relation);
  910. COMPARE_STRING_FIELD(indexname);
  911. COMPARE_SCALAR_FIELD(verbose);
  912. return true;
  913. }
  914. static bool
  915. _equalCopyStmt(const CopyStmt *a, const CopyStmt *b)
  916. {
  917. COMPARE_NODE_FIELD(relation);
  918. COMPARE_NODE_FIELD(query);
  919. COMPARE_NODE_FIELD(attlist);
  920. COMPARE_SCALAR_FIELD(is_from);
  921. COMPARE_SCALAR_FIELD(is_program);
  922. COMPARE_STRING_FIELD(filename);
  923. COMPARE_NODE_FIELD(options);
  924. return true;
  925. }
  926. static bool
  927. _equalCreateStmt(const CreateStmt *a, const CreateStmt *b)
  928. {
  929. COMPARE_NODE_FIELD(relation);
  930. COMPARE_NODE_FIELD(tableElts);
  931. COMPARE_NODE_FIELD(inhRelations);
  932. COMPARE_NODE_FIELD(ofTypename);
  933. COMPARE_NODE_FIELD(constraints);
  934. COMPARE_NODE_FIELD(options);
  935. COMPARE_SCALAR_FIELD(oncommit);
  936. COMPARE_STRING_FIELD(tablespacename);
  937. COMPARE_SCALAR_FIELD(if_not_exists);
  938. return true;
  939. }
  940. static bool
  941. _equalTableLikeClause(const TableLikeClause *a, const TableLikeClause *b)
  942. {
  943. COMPARE_NODE_FIELD(relation);
  944. COMPARE_SCALAR_FIELD(options);
  945. return true;
  946. }
  947. static bool
  948. _equalDefineStmt(const DefineStmt *a, const DefineStmt *b)
  949. {
  950. COMPARE_SCALAR_FIELD(kind);
  951. COMPARE_SCALAR_FIELD(oldstyle);
  952. COMPARE_NODE_FIELD(defnames);
  953. COMPARE_NODE_FIELD(args);
  954. COMPARE_NODE_FIELD(definition);
  955. return true;
  956. }
  957. static bool
  958. _equalDropStmt(const DropStmt *a, const DropStmt *b)
  959. {
  960. COMPARE_NODE_FIELD(objects);
  961. COMPARE_NODE_FIELD(arguments);
  962. COMPARE_SCALAR_FIELD(removeType);
  963. COMPARE_SCALAR_FIELD(behavior);
  964. COMPARE_SCALAR_FIELD(missing_ok);
  965. COMPARE_SCALAR_FIELD(concurrent);
  966. return true;
  967. }
  968. static bool
  969. _equalTruncateStmt(const TruncateStmt *a, const TruncateStmt *b)
  970. {
  971. COMPARE_NODE_FIELD(relations);
  972. COMPARE_SCALAR_FIELD(restart_seqs);
  973. COMPARE_SCALAR_FIELD(behavior);
  974. return true;
  975. }
  976. static bool
  977. _equalCommentStmt(const CommentStmt *a, const CommentStmt *b)
  978. {
  979. COMPARE_SCALAR_FIELD(objtype);
  980. COMPARE_NODE_FIELD(objname);
  981. COMPARE_NODE_FIELD(objargs);
  982. COMPARE_STRING_FIELD(comment);
  983. return true;
  984. }
  985. static bool
  986. _equalSecLabelStmt(const SecLabelStmt *a, const SecLabelStmt *b)
  987. {
  988. COMPARE_SCALAR_FIELD(objtype);
  989. COMPARE_NODE_FIELD(objname);
  990. COMPARE_NODE_FIELD(objargs);
  991. COMPARE_STRING_FIELD(provider);
  992. COMPARE_STRING_FIELD(label);
  993. return true;
  994. }
  995. static bool
  996. _equalFetchStmt(const FetchStmt *a, const FetchStmt *b)
  997. {
  998. COMPARE_SCALAR_FIELD(direction);
  999. COMPARE_SCALAR_FIELD(howMany);
  1000. COMPARE_STRING_FIELD(portalname);
  1001. COMPARE_SCALAR_FIELD(ismove);
  1002. return true;
  1003. }
  1004. static bool
  1005. _equalIndexStmt(const IndexStmt *a, const IndexStmt *b)
  1006. {
  1007. COMPARE_STRING_FIELD(idxname);
  1008. COMPARE_NODE_FIELD(relation);
  1009. COMPARE_STRING_FIELD(accessMethod);
  1010. COMPARE_STRING_FIELD(tableSpace);
  1011. COMPARE_NODE_FIELD(indexParams);
  1012. COMPARE_NODE_FIELD(options);
  1013. COMPARE_NODE_FIELD(whereClause);
  1014. COMPARE_NODE_FIELD(excludeOpNames);
  1015. COMPARE_STRING_FIELD(idxcomment);
  1016. COMPARE_SCALAR_FIELD(indexOid);
  1017. COMPARE_SCALAR_FIELD(oldNode);
  1018. COMPARE_SCALAR_FIELD(unique);
  1019. COMPARE_SCALAR_FIELD(primary);
  1020. COMPARE_SCALAR_FIELD(isconstraint);
  1021. COMPARE_SCALAR_FIELD(deferrable);
  1022. COMPARE_SCALAR_FIELD(initdeferred);
  1023. COMPARE_SCALAR_FIELD(concurrent);
  1024. return true;
  1025. }
  1026. static bool
  1027. _equalCreateFunctionStmt(const CreateFunctionStmt *a, const CreateFunctionStmt *b)
  1028. {
  1029. COMPARE_SCALAR_FIELD(replace);
  1030. COMPARE_NODE_FIELD(funcname);
  1031. COMPARE_NODE_FIELD(parameters);
  1032. COMPARE_NODE_FIELD(returnType);
  1033. COMPARE_NODE_FIELD(options);
  1034. COMPARE_NODE_FIELD(withClause);
  1035. return true;
  1036. }
  1037. static bool
  1038. _equalFunctionParameter(const FunctionParameter *a, const FunctionParameter *b)
  1039. {
  1040. COMPARE_STRING_FIELD(name);
  1041. COMPARE_NODE_FIELD(argType);
  1042. COMPARE_SCALAR_FIELD(mode);
  1043. COMPARE_NODE_FIELD(defexpr);
  1044. return true;
  1045. }
  1046. static bool
  1047. _equalAlterFunctionStmt(const AlterFunctionStmt *a, const AlterFunctionStmt *b)
  1048. {
  1049. COMPARE_NODE_FIELD(func);
  1050. COMPARE_NODE_FIELD(actions);
  1051. return true;
  1052. }
  1053. static bool
  1054. _equalDoStmt(const DoStmt *a, const DoStmt *b)
  1055. {
  1056. COMPARE_NODE_FIELD(args);
  1057. return true;
  1058. }
  1059. static bool
  1060. _equalRenameStmt(const RenameStmt *a, const RenameStmt *b)
  1061. {
  1062. COMPARE_SCALAR_FIELD(renameType);
  1063. COMPARE_SCALAR_FIELD(relationType);
  1064. COMPARE_NODE_FIELD(relation);
  1065. COMPARE_NODE_FIELD(object);
  1066. COMPARE_NODE_FIELD(objarg);
  1067. COMPARE_STRING_FIELD(subname);
  1068. COMPARE_STRING_FIELD(newname);
  1069. COMPARE_SCALAR_FIELD(behavior);
  1070. COMPARE_SCALAR_FIELD(missing_ok);
  1071. return true;
  1072. }
  1073. static bool
  1074. _equalAlterObjectSchemaStmt(const AlterObjectSchemaStmt *a, const AlterObjectSchemaStmt *b)
  1075. {
  1076. COMPARE_SCALAR_FIELD(objectType);
  1077. COMPARE_NODE_FIELD(relation);
  1078. COMPARE_NODE_FIELD(object);
  1079. COMPARE_NODE_FIELD(objarg);
  1080. COMPARE_STRING_FIELD(newschema);
  1081. COMPARE_SCALAR_FIELD(missing_ok);
  1082. return true;
  1083. }
  1084. static bool
  1085. _equalAlterOwnerStmt(const AlterOwnerStmt *a, const AlterOwnerStmt *b)
  1086. {
  1087. COMPARE_SCALAR_FIELD(objectType);
  1088. COMPARE_NODE_FIELD(relation);
  1089. COMPARE_NODE_FIELD(object);
  1090. COMPARE_NODE_FIELD(objarg);
  1091. COMPARE_STRING_FIELD(newowner);
  1092. return true;
  1093. }
  1094. static bool
  1095. _equalRuleStmt(const RuleStmt *a, const RuleStmt *b)
  1096. {
  1097. COMPARE_NODE_FIELD(relation);
  1098. COMPARE_STRING_FIELD(rulename);
  1099. COMPARE_NODE_FIELD(whereClause);
  1100. COMPARE_SCALAR_FIELD(event);
  1101. COMPARE_SCALAR_FIELD(instead);
  1102. COMPARE_NODE_FIELD(actions);
  1103. COMPARE_SCALAR_FIELD(replace);
  1104. return true;
  1105. }
  1106. static bool
  1107. _equalNotifyStmt(const NotifyStmt *a, const NotifyStmt *b)
  1108. {
  1109. COMPARE_STRING_FIELD(conditionname);
  1110. COMPARE_STRING_FIELD(payload);
  1111. return true;
  1112. }
  1113. static bool
  1114. _equalListenStmt(const ListenStmt *a, const ListenStmt *b)
  1115. {
  1116. COMPARE_STRING_FIELD(conditionname);
  1117. return true;
  1118. }
  1119. static bool
  1120. _equalUnlistenStmt(const UnlistenStmt *a, const UnlistenStmt *b)
  1121. {
  1122. COMPARE_STRING_FIELD(conditionname);
  1123. return true;
  1124. }
  1125. static bool
  1126. _equalTransactionStmt(const TransactionStmt *a, const TransactionStmt *b)
  1127. {
  1128. COMPARE_SCALAR_FIELD(kind);
  1129. COMPARE_NODE_FIELD(options);
  1130. COMPARE_STRING_FIELD(gid);
  1131. return true;
  1132. }
  1133. static bool
  1134. _equalCompositeTypeStmt(const CompositeTypeStmt *a, const CompositeTypeStmt *b)
  1135. {
  1136. COMPARE_NODE_FIELD(typevar);
  1137. COMPARE_NODE_FIELD(coldeflist);
  1138. return true;
  1139. }
  1140. static bool
  1141. _equalCreateEnumStmt(const CreateEnumStmt *a, const CreateEnumStmt *b)
  1142. {
  1143. COMPARE_NODE_FIELD(typeName);
  1144. COMPARE_NODE_FIELD(vals);
  1145. return true;
  1146. }
  1147. static bool
  1148. _equalCreateRangeStmt(const CreateRangeStmt *a, const CreateRangeStmt *b)
  1149. {
  1150. COMPARE_NODE_FIELD(typeName);
  1151. COMPARE_NODE_FIELD(params);
  1152. return true;
  1153. }
  1154. static bool
  1155. _equalAlterEnumStmt(const AlterEnumStmt *a, const AlterEnumStmt *b)
  1156. {
  1157. COMPARE_NODE_FIELD(typeName);
  1158. COMPARE_STRING_FIELD(newVal);
  1159. COMPARE_STRING_FIELD(newValNeighbor);
  1160. COMPARE_SCALAR_FIELD(newValIsAfter);
  1161. COMPARE_SCALAR_FIELD(skipIfExists);
  1162. return true;
  1163. }
  1164. static bool
  1165. _equalViewStmt(const ViewStmt *a, const ViewStmt *b)
  1166. {
  1167. COMPARE_NODE_FIELD(view);
  1168. COMPARE_NODE_FIELD(aliases);
  1169. COMPARE_NODE_FIELD(query);
  1170. COMPARE_SCALAR_FIELD(replace);
  1171. COMPARE_NODE_FIELD(options);
  1172. COMPARE_SCALAR_FIELD(withCheckOption);
  1173. return true;
  1174. }
  1175. static bool
  1176. _equalLoadStmt(const LoadStmt *a, const LoadStmt *b)
  1177. {
  1178. COMPARE_STRING_FIELD(filename);
  1179. return true;
  1180. }
  1181. static bool
  1182. _equalCreateDomainStmt(const CreateDomainStmt *a, const CreateDomainStmt *b)
  1183. {
  1184. COMPARE_NODE_FIELD(domainname);
  1185. COMPARE_NODE_FIELD(typeName);
  1186. COMPARE_NODE_FIELD(collClause);
  1187. COMPARE_NODE_FIELD(constraints);
  1188. return true;
  1189. }
  1190. static bool
  1191. _equalCreateOpClassStmt(const CreateOpClassStmt *a, const CreateOpClassStmt *b)
  1192. {
  1193. COMPARE_NODE_FIELD(opclassname);
  1194. COMPARE_NODE_FIELD(opfamilyname);
  1195. COMPARE_STRING_FIELD(amname);
  1196. COMPARE_NODE_FIELD(datatype);
  1197. COMPARE_NODE_FIELD(items);
  1198. COMPARE_SCALAR_FIELD(isDefault);
  1199. return true;
  1200. }
  1201. static bool
  1202. _equalCreateOpClassItem(const CreateOpClassItem *a, const CreateOpClassItem *b)
  1203. {
  1204. COMPARE_SCALAR_FIELD(itemtype);
  1205. COMPARE_NODE_FIELD(name);
  1206. COMPARE_NODE_FIELD(args);
  1207. COMPARE_SCALAR_FIELD(number);
  1208. COMPARE_NODE_FIELD(order_family);
  1209. COMPARE_NODE_FIELD(class_args);
  1210. COMPARE_NODE_FIELD(storedtype);
  1211. return true;
  1212. }
  1213. static bool
  1214. _equalCreateOpFamilyStmt(const CreateOpFamilyStmt *a, const CreateOpFamilyStmt *b)
  1215. {
  1216. COMPARE_NODE_FIELD(opfamilyname);
  1217. COMPARE_STRING_FIELD(amname);
  1218. return true;
  1219. }
  1220. static bool
  1221. _equalAlterOpFamilyStmt(const AlterOpFamilyStmt *a, const AlterOpFamilyStmt *b)
  1222. {
  1223. COMPARE_NODE_FIELD(opfamilyname);
  1224. COMPARE_STRING_FIELD(amname);
  1225. COMPARE_SCALAR_FIELD(isDrop);
  1226. COMPARE_NODE_FIELD(items);
  1227. return true;
  1228. }
  1229. static bool
  1230. _equalCreatedbStmt(const CreatedbStmt *a, const CreatedbStmt *b)
  1231. {
  1232. COMPARE_STRING_FIELD(dbname);
  1233. COMPARE_NODE_FIELD(options);
  1234. return true;
  1235. }
  1236. static bool
  1237. _equalAlterDatabaseStmt(const AlterDatabaseStmt *a, const AlterDatabaseStmt *b)
  1238. {
  1239. COMPARE_STRING_FIELD(dbname);
  1240. COMPARE_NODE_FIELD(options);
  1241. return true;
  1242. }
  1243. static bool
  1244. _equalAlterDatabaseSetStmt(const AlterDatabaseSetStmt *a, const AlterDatabaseSetStmt *b)
  1245. {
  1246. COMPARE_STRING_FIELD(dbname);
  1247. COMPARE_NODE_FIELD(setstmt);
  1248. return true;
  1249. }
  1250. static bool
  1251. _equalDropdbStmt(const DropdbStmt *a, const DropdbStmt *b)
  1252. {
  1253. COMPARE_STRING_FIELD(dbname);
  1254. COMPARE_SCALAR_FIELD(missing_ok);
  1255. return true;
  1256. }
  1257. static bool
  1258. _equalVacuumStmt(const VacuumStmt *a, const VacuumStmt *b)
  1259. {
  1260. COMPARE_SCALAR_FIELD(options);
  1261. COMPARE_SCALAR_FIELD(freeze_min_age);
  1262. COMPARE_SCALAR_FIELD(freeze_table_age);
  1263. COMPARE_SCALAR_FIELD(multixact_freeze_min_age);
  1264. COMPARE_SCALAR_FIELD(multixact_freeze_table_age);
  1265. COMPARE_NODE_FIELD(relation);
  1266. COMPARE_NODE_FIELD(va_cols);
  1267. return true;
  1268. }
  1269. static bool
  1270. _equalExplainStmt(const ExplainStmt *a, const ExplainStmt *b)
  1271. {
  1272. COMPARE_NODE_FIELD(query);
  1273. COMPARE_NODE_FIELD(options);
  1274. return true;
  1275. }
  1276. static bool
  1277. _equalCreateTableAsStmt(const CreateTableAsStmt *a, const CreateTableAsStmt *b)
  1278. {
  1279. COMPARE_NODE_FIELD(query);
  1280. COMPARE_NODE_FIELD(into);
  1281. COMPARE_SCALAR_FIELD(relkind);
  1282. COMPARE_SCALAR_FIELD(is_select_into);
  1283. return true;
  1284. }
  1285. static bool
  1286. _equalRefreshMatViewStmt(const RefreshMatViewStmt *a, const RefreshMatViewStmt *b)
  1287. {
  1288. COMPARE_SCALAR_FIELD(concurrent);
  1289. COMPARE_SCALAR_FIELD(skipData);
  1290. COMPARE_NODE_FIELD(relation);
  1291. return true;
  1292. }
  1293. static bool
  1294. _equalReplicaIdentityStmt(const ReplicaIdentityStmt *a, const ReplicaIdentityStmt *b)
  1295. {
  1296. COMPARE_SCALAR_FIELD(identity_type);
  1297. COMPARE_STRING_FIELD(name);
  1298. return true;
  1299. }
  1300. static bool
  1301. _equalAlterSystemStmt(const AlterSystemStmt *a, const AlterSystemStmt *b)
  1302. {
  1303. COMPARE_NODE_FIELD(setstmt);
  1304. return true;
  1305. }
  1306. static bool
  1307. _equalCreateSeqStmt(const CreateSeqStmt *a, const CreateSeqStmt *b)
  1308. {
  1309. COMPARE_NODE_FIELD(sequence);
  1310. COMPARE_NODE_FIELD(options);
  1311. COMPARE_SCALAR_FIELD(ownerId);
  1312. return true;
  1313. }
  1314. static bool
  1315. _equalAlterSeqStmt(const AlterSeqStmt *a, const AlterSeqStmt *b)
  1316. {
  1317. COMPARE_NODE_FIELD(sequence);
  1318. COMPARE_NODE_FIELD(options);
  1319. COMPARE_SCALAR_FIELD(missing_ok);
  1320. return true;
  1321. }
  1322. static bool
  1323. _equalVariableSetStmt(const VariableSetStmt *a, const VariableSetStmt *b)
  1324. {
  1325. COMPARE_SCALAR_FIELD(kind);
  1326. COMPARE_STRING_FIELD(name);
  1327. COMPARE_NODE_FIELD(args);
  1328. COMPARE_SCALAR_FIELD(is_local);
  1329. return true;
  1330. }
  1331. static bool
  1332. _equalVariableShowStmt(const VariableShowStmt *a, const VariableShowStmt *b)
  1333. {
  1334. COMPARE_STRING_FIELD(name);
  1335. return true;
  1336. }
  1337. static bool
  1338. _equalDiscardStmt(const DiscardStmt *a, const DiscardStmt *b)
  1339. {
  1340. COMPARE_SCALAR_FIELD(target);
  1341. return true;
  1342. }
  1343. static bool
  1344. _equalCreateTableSpaceStmt(const CreateTableSpaceStmt *a, const CreateTableSpaceStmt *b)
  1345. {
  1346. COMPARE_STRING_FIELD(tablespacename);
  1347. COMPARE_STRING_FIELD(owner);
  1348. COMPARE_STRING_FIELD(location);
  1349. COMPARE_NODE_FIELD(options);
  1350. return true;
  1351. }
  1352. static bool
  1353. _equalDropTableSpaceStmt(const DropTableSpaceStmt *a, const DropTableSpaceStmt *b)
  1354. {
  1355. COMPARE_STRING_FIELD(tablespacename);
  1356. COMPARE_SCALAR_FIELD(missing_ok);
  1357. return true;
  1358. }
  1359. static bool
  1360. _equalAlterTableSpaceOptionsStmt(const AlterTableSpaceOptionsStmt *a,
  1361. const AlterTableSpaceOptionsStmt *b)
  1362. {
  1363. COMPARE_STRING_FIELD(tablespacename);
  1364. COMPARE_NODE_FIELD(options);
  1365. COMPARE_SCALAR_FIELD(isReset);
  1366. return true;
  1367. }
  1368. static bool
  1369. _equalAlterTableSpaceMoveStmt(const AlterTableSpaceMoveStmt *a,
  1370. const AlterTableSpaceMoveStmt *b)
  1371. {
  1372. COMPARE_STRING_FIELD(orig_tablespacename);
  1373. COMPARE_SCALAR_FIELD(objtype);
  1374. COMPARE_SCALAR_FIELD(move_all);
  1375. COMPARE_NODE_FIELD(roles);
  1376. COMPARE_STRING_FIELD(new_tablespacename);
  1377. COMPARE_SCALAR_FIELD(nowait);
  1378. return true;
  1379. }
  1380. static bool
  1381. _equalCreateExtensionStmt(const CreateExtensionStmt *a, const CreateExtensionStmt *b)
  1382. {
  1383. COMPARE_STRING_FIELD(extname);
  1384. COMPARE_SCALAR_FIELD(if_not_exists);
  1385. COMPARE_NODE_FIELD(options);
  1386. return true;
  1387. }
  1388. static bool
  1389. _equalAlterExtensionStmt(const AlterExtensionStmt *a, const AlterExtensionStmt *b)
  1390. {
  1391. COMPARE_STRING_FIELD(extname);
  1392. COMPARE_NODE_FIELD(options);
  1393. return true;
  1394. }
  1395. static bool
  1396. _equalAlterExtensionContentsStmt(const AlterExtensionContentsStmt *a, const AlterExtensionContentsStmt *b)
  1397. {
  1398. COMPARE_STRING_FIELD(extname);
  1399. COMPARE_SCALAR_FIELD(action);
  1400. COMPARE_SCALAR_FIELD(objtype);
  1401. COMPARE_NODE_FIELD(objname);
  1402. COMPARE_NODE_FIELD(objargs);
  1403. return true;
  1404. }
  1405. static bool
  1406. _equalCreateFdwStmt(const CreateFdwStmt *a, const CreateFdwStmt *b)
  1407. {
  1408. COMPARE_STRING_FIELD(fdwname);
  1409. COMPARE_NODE_FIELD(func_options);
  1410. COMPARE_NODE_FIELD(options);
  1411. return true;
  1412. }
  1413. static bool
  1414. _equalAlterFdwStmt(const AlterFdwStmt *a, const AlterFdwStmt *b)
  1415. {
  1416. COMPARE_STRING_FIELD(fdwname);
  1417. COMPARE_NODE_FIELD(func_options);
  1418. COMPARE_NODE_FIELD(options);
  1419. return true;
  1420. }
  1421. static bool
  1422. _equalCreateForeignServerStmt(const CreateForeignServerStmt *a, const CreateForeignServerStmt *b)
  1423. {
  1424. COMPARE_STRING_FIELD(servername);
  1425. COMPARE_STRING_FIELD(servertype);
  1426. COMPARE_STRING_FIELD(version);
  1427. COMPARE_STRING_FIELD(fdwname);
  1428. COMPARE_NODE_FIELD(options);
  1429. return true;
  1430. }
  1431. static bool
  1432. _equalAlterForeignServerStmt(const AlterForeignServerStmt *a, const AlterForeignServerStmt *b)
  1433. {
  1434. COMPARE_STRING_FIELD(servername);
  1435. COMPARE_STRING_FIELD(version);
  1436. COMPARE_NODE_FIELD(options);
  1437. COMPARE_SCALAR_FIELD(has_version);
  1438. return true;
  1439. }
  1440. static bool
  1441. _equalCreateUserMappingStmt(const CreateUserMappingStmt *a, const CreateUserMappingStmt *b)
  1442. {
  1443. COMPARE_STRING_FIELD(username);
  1444. COMPARE_STRING_FIELD(servername);
  1445. COMPARE_NODE_FIELD(options);
  1446. return true;
  1447. }
  1448. static bool
  1449. _equalAlterUserMappingStmt(const AlterUserMappingStmt *a, const AlterUserMappingStmt *b)
  1450. {
  1451. COMPARE_STRING_FIELD(username);
  1452. COMPARE_STRING_FIELD(servername);
  1453. COMPARE_NODE_FIELD(options);
  1454. return true;
  1455. }
  1456. static bool
  1457. _equalDropUserMappingStmt(const DropUserMappingStmt *a, const DropUserMappingStmt *b)
  1458. {
  1459. COMPARE_STRING_FIELD(username);
  1460. COMPARE_STRING_FIELD(servername);
  1461. COMPARE_SCALAR_FIELD(missing_ok);
  1462. return true;
  1463. }
  1464. static bool
  1465. _equalCreateForeignTableStmt(const CreateForeignTableStmt *a, const CreateForeignTableStmt *b)
  1466. {
  1467. if (!_equalCreateStmt(&a->base, &b->base))
  1468. return false;
  1469. COMPARE_STRING_FIELD(servername);
  1470. COMPARE_NODE_FIELD(options);
  1471. return true;
  1472. }
  1473. static bool
  1474. _equalCreateTrigStmt(const CreateTrigStmt *a, const CreateTrigStmt *b)
  1475. {
  1476. COMPARE_STRING_FIELD(trigname);
  1477. COMPARE_NODE_FIELD(relation);
  1478. COMPARE_NODE_FIELD(funcname);
  1479. COMPARE_NODE_FIELD(args);
  1480. COMPARE_SCALAR_FIELD(row);
  1481. COMPARE_SCALAR_FIELD(timing);
  1482. COMPARE_SCALAR_FIELD(events);
  1483. COMPARE_NODE_FIELD(columns);
  1484. COMPARE_NODE_FIELD(whenClause);
  1485. COMPARE_SCALAR_FIELD(isconstraint);
  1486. COMPARE_SCALAR_FIELD(deferrable);
  1487. COMPARE_SCALAR_FIELD(initdeferred);
  1488. COMPARE_NODE_FIELD(constrrel);
  1489. return true;
  1490. }
  1491. static bool
  1492. _equalCreateEventTrigStmt(const CreateEventTrigStmt *a, const CreateEventTrigStmt *b)
  1493. {
  1494. COMPARE_STRING_FIELD(trigname);
  1495. COMPARE_SCALAR_FIELD(eventname);
  1496. COMPARE_NODE_FIELD(funcname);
  1497. COMPARE_NODE_FIELD(whenclause);
  1498. return true;
  1499. }
  1500. static bool
  1501. _equalAlterEventTrigStmt(const AlterEventTrigStmt *a, const AlterEventTrigStmt *b)
  1502. {
  1503. COMPARE_STRING_FIELD(trigname);
  1504. COMPARE_SCALAR_FIELD(tgenabled);
  1505. return true;
  1506. }
  1507. static bool
  1508. _equalCreatePLangStmt(const CreatePLangStmt *a, const CreatePLangStmt *b)
  1509. {
  1510. COMPARE_SCALAR_FIELD(replace);
  1511. COMPARE_STRING_FIELD(plname);
  1512. COMPARE_NODE_FIELD(plhandler);
  1513. COMPARE_NODE_FIELD(plinline);
  1514. COMPARE_NODE_FIELD(plvalidator);
  1515. COMPARE_SCALAR_FIELD(pltrusted);
  1516. return true;
  1517. }
  1518. static bool
  1519. _equalCreateRoleStmt(const CreateRoleStmt *a, const CreateRoleStmt *b)
  1520. {
  1521. COMPARE_SCALAR_FIELD(stmt_type);
  1522. COMPARE_STRING_FIELD(role);
  1523. COMPARE_NODE_FIELD(options);
  1524. return true;
  1525. }
  1526. static bool
  1527. _equalAlterRoleStmt(const AlterRoleStmt *a, const AlterRoleStmt *b)
  1528. {
  1529. COMPARE_STRING_FIELD(role);
  1530. COMPARE_NODE_FIELD(options);
  1531. COMPARE_SCALAR_FIELD(action);
  1532. return true;
  1533. }
  1534. static bool
  1535. _equalAlterRoleSetStmt(const AlterRoleSetStmt *a, const AlterRoleSetStmt *b)
  1536. {
  1537. COMPARE_STRING_FIELD(role);
  1538. COMPARE_STRING_FIELD(database);
  1539. COMPARE_NODE_FIELD(setstmt);
  1540. return true;
  1541. }
  1542. static bool
  1543. _equalDropRoleStmt(const DropRoleStmt *a, const DropRoleStmt *b)
  1544. {
  1545. COMPARE_NODE_FIELD(roles);
  1546. COMPARE_SCALAR_FIELD(missing_ok);
  1547. return true;
  1548. }
  1549. static bool
  1550. _equalLockStmt(const LockStmt *a, const LockStmt *b)
  1551. {
  1552. COMPARE_NODE_FIELD(relations);
  1553. COMPARE_SCALAR_FIELD(mode);
  1554. COMPARE_SCALAR_FIELD(nowait);
  1555. return true;
  1556. }
  1557. static bool
  1558. _equalConstraintsSetStmt(const ConstraintsSetStmt *a, const ConstraintsSetStmt *b)
  1559. {
  1560. COMPARE_NODE_FIELD(constraints);
  1561. COMPARE_SCALAR_FIELD(deferred);
  1562. return true;
  1563. }
  1564. static bool
  1565. _equalReindexStmt(const ReindexStmt *a, const ReindexStmt *b)
  1566. {
  1567. COMPARE_SCALAR_FIELD(kind);
  1568. COMPARE_NODE_FIELD(relation);
  1569. COMPARE_STRING_FIELD(name);
  1570. COMPARE_SCALAR_FIELD(do_system);
  1571. COMPARE_SCALAR_FIELD(do_user);
  1572. return true;
  1573. }
  1574. static bool
  1575. _equalCreateSchemaStmt(const CreateSchemaStmt *a, const CreateSchemaStmt *b)
  1576. {
  1577. COMPARE_STRING_FIELD(schemaname);
  1578. COMPARE_STRING_FIELD(authid);
  1579. COMPARE_NODE_FIELD(schemaElts);
  1580. COMPARE_SCALAR_FIELD(if_not_exists);
  1581. return true;
  1582. }
  1583. static bool
  1584. _equalCreateConversionStmt(const CreateConversionStmt *a, const CreateConversionStmt *b)
  1585. {
  1586. COMPARE_NODE_FIELD(conversion_name);
  1587. COMPARE_STRING_FIELD(for_encoding_name);
  1588. COMPARE_STRING_FIELD(to_encoding_name);
  1589. COMPARE_NODE_FIELD(func_name);
  1590. COMPARE_SCALAR_FIELD(def);
  1591. return true;
  1592. }
  1593. static bool
  1594. _equalCreateCastStmt(const CreateCastStmt *a, const CreateCastStmt *b)
  1595. {
  1596. COMPARE_NODE_FIELD(sourcetype);
  1597. COMPARE_NODE_FIELD(targettype);
  1598. COMPARE_NODE_FIELD(func);
  1599. COMPARE_SCALAR_FIELD(context);
  1600. COMPARE_SCALAR_FIELD(inout);
  1601. return true;
  1602. }
  1603. static bool
  1604. _equalPrepareStmt(const PrepareStmt *a, const PrepareStmt *b)
  1605. {
  1606. COMPARE_STRING_FIELD(name);
  1607. COMPARE_NODE_FIELD(argtypes);
  1608. COMPARE_NODE_FIELD(query);
  1609. return true;
  1610. }
  1611. static bool
  1612. _equalExecuteStmt(const ExecuteStmt *a, const ExecuteStmt *b)
  1613. {
  1614. COMPARE_STRING_FIELD(name);
  1615. COMPARE_NODE_FIELD(params);
  1616. return true;
  1617. }
  1618. static bool
  1619. _equalDeallocateStmt(const DeallocateStmt *a, const DeallocateStmt *b)
  1620. {
  1621. COMPARE_STRING_FIELD(name);
  1622. return true;
  1623. }
  1624. static bool
  1625. _equalDropOwnedStmt(const DropOwnedStmt *a, const DropOwnedStmt *b)
  1626. {
  1627. COMPARE_NODE_FIELD(roles);
  1628. COMPARE_SCALAR_FIELD(behavior);
  1629. return true;
  1630. }
  1631. static bool
  1632. _equalReassignOwnedStmt(const ReassignOwnedStmt *a, const ReassignOwnedStmt *b)
  1633. {
  1634. COMPARE_NODE_FIELD(roles);
  1635. COMPARE_STRING_FIELD(newrole);
  1636. return true;
  1637. }
  1638. static bool
  1639. _equalAlterTSDictionaryStmt(const AlterTSDictionaryStmt *a, const AlterTSDictionaryStmt *b)
  1640. {
  1641. COMPARE_NODE_FIELD(dictname);
  1642. COMPARE_NODE_FIELD(options);
  1643. return true;
  1644. }
  1645. static bool
  1646. _equalAlterTSConfigurationStmt(const AlterTSConfigurationStmt *a,
  1647. const AlterTSConfigurationStmt *b)
  1648. {
  1649. COMPARE_NODE_FIELD(cfgname);
  1650. COMPARE_NODE_FIELD(tokentype);
  1651. COMPARE_NODE_FIELD(dicts);
  1652. COMPARE_SCALAR_FIELD(override);
  1653. COMPARE_SCALAR_FIELD(replace);
  1654. COMPARE_SCALAR_FIELD(missing_ok);
  1655. return true;
  1656. }
  1657. static bool
  1658. _equalAExpr(const A_Expr *a, const A_Expr *b)
  1659. {
  1660. COMPARE_SCALAR_FIELD(kind);
  1661. COMPARE_NODE_FIELD(name);
  1662. COMPARE_NODE_FIELD(lexpr);
  1663. COMPARE_NODE_FIELD(rexpr);
  1664. COMPARE_LOCATION_FIELD(location);
  1665. return true;
  1666. }
  1667. static bool
  1668. _equalColumnRef(const ColumnRef *a, const ColumnRef *b)
  1669. {
  1670. COMPARE_NODE_FIELD(fields);
  1671. COMPARE_LOCATION_FIELD(location);
  1672. return true;
  1673. }
  1674. static bool
  1675. _equalParamRef(const ParamRef *a, const ParamRef *b)
  1676. {
  1677. COMPARE_SCALAR_FIELD(number);
  1678. COMPARE_LOCATION_FIELD(location);
  1679. return true;
  1680. }
  1681. static bool
  1682. _equalAConst(const A_Const *a, const A_Const *b)
  1683. {
  1684. if (!equal(&a->val, &b->val)) /* hack for in-line Value field */
  1685. return false;
  1686. COMPARE_LOCATION_FIELD(location);
  1687. return true;
  1688. }
  1689. static bool
  1690. _equalFuncCall(const FuncCall *a, const FuncCall *b)
  1691. {
  1692. COMPARE_NODE_FIELD(funcname);
  1693. COMPARE_NODE_FIELD(args);
  1694. COMPARE_NODE_FIELD(agg_order);
  1695. COMPARE_NODE_FIELD(agg_filter);
  1696. COMPARE_SCALAR_FIELD(agg_within_group);
  1697. COMPARE_SCALAR_FIELD(agg_star);
  1698. COMPARE_SCALAR_FIELD(agg_distinct);
  1699. COMPARE_SCALAR_FIELD(func_variadic);
  1700. COMPARE_NODE_FIELD(over);
  1701. COMPARE_LOCATION_FIELD(location);
  1702. return true;
  1703. }
  1704. static bool
  1705. _equalAStar(const A_Star *a, const A_Star *b)
  1706. {
  1707. return true;
  1708. }
  1709. static bool
  1710. _equalAIndices(const A_Indices *a, const A_Indices *b)
  1711. {
  1712. COMPARE_NODE_FIELD(lidx);
  1713. COMPARE_NODE_FIELD(uidx);
  1714. return true;
  1715. }
  1716. static bool
  1717. _equalA_Indirection(const A_Indirection *a, const A_Indirection *b)
  1718. {
  1719. COMPARE_NODE_FIELD(arg);
  1720. COMPARE_NODE_FIELD(indirection);
  1721. return true;
  1722. }
  1723. static bool
  1724. _equalA_ArrayExpr(const A_ArrayExpr *a, const A_ArrayExpr *b)
  1725. {
  1726. COMPARE_NODE_FIELD(elements);
  1727. COMPARE_LOCATION_FIELD(location);
  1728. return true;
  1729. }
  1730. static bool
  1731. _equalResTarget(const ResTarget *a, const ResTarget *b)
  1732. {
  1733. COMPARE_STRING_FIELD(name);
  1734. COMPARE_NODE_FIELD(indirection);
  1735. COMPARE_NODE_FIELD(val);
  1736. COMPARE_LOCATION_FIELD(location);
  1737. return true;
  1738. }
  1739. static bool
  1740. _equalTypeName(const TypeName *a, const TypeName *b)
  1741. {
  1742. COMPARE_NODE_FIELD(names);
  1743. COMPARE_SCALAR_FIELD(typeOid);
  1744. COMPARE_SCALAR_FIELD(setof);
  1745. COMPARE_SCALAR_FIELD(pct_type);
  1746. COMPARE_NODE_FIELD(typmods);
  1747. COMPARE_SCALAR_FIELD(typemod);
  1748. COMPARE_NODE_FIELD(arrayBounds);
  1749. COMPARE_LOCATION_FIELD(location);
  1750. return true;
  1751. }
  1752. static bool
  1753. _equalTypeCast(const TypeCast *a, const TypeCast *b)
  1754. {
  1755. COMPARE_NODE_FIELD(arg);
  1756. COMPARE_NODE_FIELD(typeName);
  1757. COMPARE_LOCATION_FIELD(location);
  1758. return true;
  1759. }
  1760. static bool
  1761. _equalCollateClause(const CollateClause *a, const CollateClause *b)
  1762. {
  1763. COMPARE_NODE_FIELD(arg);
  1764. COMPARE_NODE_FIELD(collname);
  1765. COMPARE_LOCATION_FIELD(location);
  1766. return true;
  1767. }
  1768. static bool
  1769. _equalSortBy(const SortBy *a, const SortBy *b)
  1770. {
  1771. COMPARE_NODE_FIELD(node);
  1772. COMPARE_SCALAR_FIELD(sortby_dir);
  1773. COMPARE_SCALAR_FIELD(sortby_nulls);
  1774. COMPARE_NODE_FIELD(useOp);
  1775. COMPARE_LOCATION_FIELD(location);
  1776. return true;
  1777. }
  1778. static bool
  1779. _equalWindowDef(const WindowDef *a, const WindowDef *b)
  1780. {
  1781. COMPARE_STRING_FIELD(name);
  1782. COMPARE_STRING_FIELD(refname);
  1783. COMPARE_NODE_FIELD(partitionClause);
  1784. COMPARE_NODE_FIELD(orderClause);
  1785. COMPARE_SCALAR_FIELD(frameOptions);
  1786. COMPARE_NODE_FIELD(startOffset);
  1787. COMPARE_NODE_FIELD(endOffset);
  1788. COMPARE_LOCATION_FIELD(location);
  1789. return true;
  1790. }
  1791. static bool
  1792. _equalRangeSubselect(const RangeSubselect *a, const RangeSubselect *b)
  1793. {
  1794. COMPARE_SCALAR_FIELD(lateral);
  1795. COMPARE_NODE_FIELD(subquery);
  1796. COMPARE_NODE_FIELD(alias);
  1797. return true;
  1798. }
  1799. static bool
  1800. _equalRangeFunction(const RangeFunction *a, const RangeFunction *b)
  1801. {
  1802. COMPARE_SCALAR_FIELD(lateral);
  1803. COMPARE_SCALAR_FIELD(ordinality);
  1804. COMPARE_SCALAR_FIELD(is_rowsfrom);
  1805. COMPARE_NODE_FIELD(functions);
  1806. COMPARE_NODE_FIELD(alias);
  1807. COMPARE_NODE_FIELD(coldeflist);
  1808. return true;
  1809. }
  1810. static bool
  1811. _equalIndexElem(const IndexElem *a, const IndexElem *b)
  1812. {
  1813. COMPARE_STRING_FIELD(name);
  1814. COMPARE_NODE_FIELD(expr);
  1815. COMPARE_STRING_FIELD(indexcolname);
  1816. COMPARE_NODE_FIELD(collation);
  1817. COMPARE_NODE_FIELD(opclass);
  1818. COMPARE_SCALAR_FIELD(ordering);
  1819. COMPARE_SCALAR_FIELD(nulls_ordering);
  1820. return true;
  1821. }
  1822. static bool
  1823. _equalColumnDef(const ColumnDef *a, const ColumnDef *b)
  1824. {
  1825. COMPARE_STRING_FIELD(colname);
  1826. COMPARE_NODE_FIELD(typeName);
  1827. COMPARE_SCALAR_FIELD(inhcount);
  1828. COMPARE_SCALAR_FIELD(is_local);
  1829. COMPARE_SCALAR_FIELD(is_not_null);
  1830. COMPARE_SCALAR_FIELD(is_from_type);
  1831. COMPARE_SCALAR_FIELD(storage);
  1832. COMPARE_NODE_FIELD(raw_default);
  1833. COMPARE_NODE_FIELD(cooked_default);
  1834. COMPARE_NODE_FIELD(collClause);
  1835. COMPARE_SCALAR_FIELD(collOid);
  1836. COMPARE_NODE_FIELD(constraints);
  1837. COMPARE_NODE_FIELD(fdwoptions);
  1838. COMPARE_LOCATION_FIELD(location);
  1839. return true;
  1840. }
  1841. static bool
  1842. _equalConstraint(const Constraint *a, const Constraint *b)
  1843. {
  1844. COMPARE_SCALAR_FIELD(contype);
  1845. COMPARE_STRING_FIELD(conname);
  1846. COMPARE_SCALAR_FIELD(deferrable);
  1847. COMPARE_SCALAR_FIELD(initdeferred);
  1848. COMPARE_LOCATION_FIELD(location);
  1849. COMPARE_SCALAR_FIELD(is_no_inherit);
  1850. COMPARE_NODE_FIELD(raw_expr);
  1851. COMPARE_STRING_FIELD(cooked_expr);
  1852. COMPARE_NODE_FIELD(keys);
  1853. COMPARE_NODE_FIELD(exclusions);
  1854. COMPARE_NODE_FIELD(options);
  1855. COMPARE_STRING_FIELD(indexname);
  1856. COMPARE_STRING_FIELD(indexspace);
  1857. COMPARE_STRING_FIELD(access_method);
  1858. COMPARE_NODE_FIELD(where_clause);
  1859. COMPARE_NODE_FIELD(pktable);
  1860. COMPARE_NODE_FIELD(fk_attrs);
  1861. COMPARE_NODE_FIELD(pk_attrs);
  1862. COMPARE_SCALAR_FIELD(fk_matchtype);
  1863. COMPARE_SCALAR_FIELD(fk_upd_action);
  1864. COMPARE_SCALAR_FIELD(fk_del_action);
  1865. COMPARE_NODE_FIELD(old_conpfeqop);
  1866. COMPARE_SCALAR_FIELD(old_pktable_oid);
  1867. COMPARE_SCALAR_FIELD(skip_validation);
  1868. COMPARE_SCALAR_FIELD(initially_valid);
  1869. return true;
  1870. }
  1871. static bool
  1872. _equalDefElem(const DefElem *a, const DefElem *b)
  1873. {
  1874. COMPARE_STRING_FIELD(defnamespace);
  1875. COMPARE_STRING_FIELD(defname);
  1876. COMPARE_NODE_FIELD(arg);
  1877. COMPARE_SCALAR_FIELD(defaction);
  1878. return true;
  1879. }
  1880. static bool
  1881. _equalLockingClause(const LockingClause *a, const LockingClause *b)
  1882. {
  1883. COMPARE_NODE_FIELD(lockedRels);
  1884. COMPARE_SCALAR_FIELD(strength);
  1885. COMPARE_SCALAR_FIELD(noWait);
  1886. return true;
  1887. }
  1888. static bool
  1889. _equalRangeTblEntry(const RangeTblEntry *a, const RangeTblEntry *b)
  1890. {
  1891. COMPARE_SCALAR_FIELD(rtekind);
  1892. COMPARE_SCALAR_FIELD(relid);
  1893. COMPARE_SCALAR_FIELD(relkind);
  1894. COMPARE_NODE_FIELD(subquery);
  1895. COMPARE_SCALAR_FIELD(security_barrier);
  1896. COMPARE_SCALAR_FIELD(jointype);
  1897. COMPARE_NODE_FIELD(joinaliasvars);
  1898. COMPARE_NODE_FIELD(functions);
  1899. COMPARE_SCALAR_FIELD(funcordinality);
  1900. COMPARE_NODE_FIELD(values_lists);
  1901. COMPARE_NODE_FIELD(values_collations);
  1902. COMPARE_STRING_FIELD(ctename);
  1903. COMPARE_SCALAR_FIELD(ctelevelsup);
  1904. COMPARE_SCALAR_FIELD(self_reference);
  1905. COMPARE_NODE_FIELD(ctecoltypes);
  1906. COMPARE_NODE_FIELD(ctecoltypmods);
  1907. COMPARE_NODE_FIELD(ctecolcollations);
  1908. COMPARE_NODE_FIELD(alias);
  1909. COMPARE_NODE_FIELD(eref);
  1910. COMPARE_SCALAR_FIELD(lateral);
  1911. COMPARE_SCALAR_FIELD(inh);
  1912. COMPARE_SCALAR_FIELD(inFromCl);
  1913. COMPARE_SCALAR_FIELD(requiredPerms);
  1914. COMPARE_SCALAR_FIELD(checkAsUser);
  1915. COMPARE_BITMAPSET_FIELD(selectedCols);
  1916. COMPARE_BITMAPSET_FIELD(modifiedCols);
  1917. COMPARE_NODE_FIELD(securityQuals);
  1918. return true;
  1919. }
  1920. static bool
  1921. _equalRangeTblFunction(const RangeTblFunction *a, const RangeTblFunction *b)
  1922. {
  1923. COMPARE_NODE_FIELD(funcexpr);
  1924. COMPARE_SCALAR_FIELD(funccolcount);
  1925. COMPARE_NODE_FIELD(funccolnames);
  1926. COMPARE_NODE_FIELD(funccoltypes);
  1927. COMPARE_NODE_FIELD(funccoltypmods);
  1928. COMPARE_NODE_FIELD(funccolcollations);
  1929. COMPARE_BITMAPSET_FIELD(funcparams);
  1930. return true;
  1931. }
  1932. static bool
  1933. _equalWithCheckOption(const WithCheckOption *a, const WithCheckOption *b)
  1934. {
  1935. COMPARE_STRING_FIELD(viewname);
  1936. COMPARE_NODE_FIELD(qual);
  1937. COMPARE_SCALAR_FIELD(cascaded);
  1938. return true;
  1939. }
  1940. static bool
  1941. _equalSortGroupClause(const SortGroupClause *a, const SortGroupClause *b)
  1942. {
  1943. COMPARE_SCALAR_FIELD(tleSortGroupRef);
  1944. COMPARE_SCALAR_FIELD(eqop);
  1945. COMPARE_SCALAR_FIELD(sortop);
  1946. COMPARE_SCALAR_FIELD(nulls_first);
  1947. COMPARE_SCALAR_FIELD(hashable);
  1948. return true;
  1949. }
  1950. static bool
  1951. _equalWindowClause(const WindowClause *a, const WindowClause *b)
  1952. {
  1953. COMPARE_STRING_FIELD(name);
  1954. COMPARE_STRING_FIELD(refname);
  1955. COMPARE_NODE_FIELD(partitionClause);
  1956. COMPARE_NODE_FIELD(orderClause);
  1957. COMPARE_SCALAR_FIELD(frameOptions);
  1958. COMPARE_NODE_FIELD(startOffset);
  1959. COMPARE_NODE_FIELD(endOffset);
  1960. COMPARE_SCALAR_FIELD(winref);
  1961. COMPARE_SCALAR_FIELD(copiedOrder);
  1962. return true;
  1963. }
  1964. static bool
  1965. _equalRowMarkClause(const RowMarkClause *a, const RowMarkClause *b)
  1966. {
  1967. COMPARE_SCALAR_FIELD(rti);
  1968. COMPARE_SCALAR_FIELD(strength);
  1969. COMPARE_SCALAR_FIELD(noWait);
  1970. COMPARE_SCALAR_FIELD(pushedDown);
  1971. return true;
  1972. }
  1973. static bool
  1974. _equalWithClause(const WithClause *a, const WithClause *b)
  1975. {
  1976. COMPARE_NODE_FIELD(ctes);
  1977. COMPARE_SCALAR_FIELD(recursive);
  1978. COMPARE_LOCATION_FIELD(location);
  1979. return true;
  1980. }
  1981. static bool
  1982. _equalCommonTableExpr(const CommonTableExpr *a, const CommonTableExpr *b)
  1983. {
  1984. COMPARE_STRING_FIELD(ctename);
  1985. COMPARE_NODE_FIELD(aliascolnames);
  1986. COMPARE_NODE_FIELD(ctequery);
  1987. COMPARE_LOCATION_FIELD(location);
  1988. COMPARE_SCALAR_FIELD(cterecursive);
  1989. COMPARE_SCALAR_FIELD(cterefcount);
  1990. COMPARE_NODE_FIELD(ctecolnames);
  1991. COMPARE_NODE_FIELD(ctecoltypes);
  1992. COMPARE_NODE_FIELD(ctecoltypmods);
  1993. COMPARE_NODE_FIELD(ctecolcollations);
  1994. return true;
  1995. }
  1996. static bool
  1997. _equalXmlSerialize(const XmlSerialize *a, const XmlSerialize *b)
  1998. {
  1999. COMPARE_SCALAR_FIELD(xmloption);
  2000. COMPARE_NODE_FIELD(expr);
  2001. COMPARE_NODE_FIELD(typeName);
  2002. COMPARE_LOCATION_FIELD(location);
  2003. return true;
  2004. }
  2005. /*
  2006. * Stuff from pg_list.h
  2007. */
  2008. static bool
  2009. _equalList(const List *a, const List *b)
  2010. {
  2011. const ListCell *item_a;
  2012. const ListCell *item_b;
  2013. /*
  2014. * Try to reject by simple scalar checks before grovelling through all the
  2015. * list elements...
  2016. */
  2017. COMPARE_SCALAR_FIELD(type);
  2018. COMPARE_SCALAR_FIELD(length);
  2019. /*
  2020. * We place the switch outside the loop for the sake of efficiency; this
  2021. * may not be worth doing...
  2022. */
  2023. switch (a->type)
  2024. {
  2025. case T_List:
  2026. forboth(item_a, a, item_b, b)
  2027. {
  2028. if (!equal(lfirst(item_a), lfirst(item_b)))
  2029. return false;
  2030. }
  2031. break;
  2032. case T_IntList:
  2033. forboth(item_a, a, item_b, b)
  2034. {
  2035. if (lfirst_int(item_a) != lfirst_int(item_b))
  2036. return false;
  2037. }
  2038. break;
  2039. case T_OidList:
  2040. forboth(item_a, a, item_b, b)
  2041. {
  2042. if (lfirst_oid(item_a) != lfirst_oid(item_b))
  2043. return false;
  2044. }
  2045. break;
  2046. default:
  2047. elog(ERROR, "unrecognized list node type: %d",
  2048. (int) a->type);
  2049. return false; /* keep compiler quiet */
  2050. }
  2051. /*
  2052. * If we got here, we should have run out of elements of both lists
  2053. */
  2054. Assert(item_a == NULL);
  2055. Assert(item_b == NULL);
  2056. return true;
  2057. }
  2058. /*
  2059. * Stuff from value.h
  2060. */
  2061. static bool
  2062. _equalValue(const Value *a, const Value *b)
  2063. {
  2064. COMPARE_SCALAR_FIELD(type);
  2065. switch (a->type)
  2066. {
  2067. case T_Integer:
  2068. COMPARE_SCALAR_FIELD(val.ival);
  2069. break;
  2070. case T_Float:
  2071. case T_String:
  2072. case T_BitString:
  2073. COMPARE_STRING_FIELD(val.str);
  2074. break;
  2075. case T_Null:
  2076. /* nothing to do */
  2077. break;
  2078. default:
  2079. elog(ERROR, "unrecognized node type: %d", (int) a->type);
  2080. break;
  2081. }
  2082. return true;
  2083. }
  2084. /*
  2085. * equal
  2086. * returns whether two nodes are equal
  2087. */
  2088. bool
  2089. equal(const void *a, const void *b)
  2090. {
  2091. bool retval;
  2092. if (a == b)
  2093. return true;
  2094. /*
  2095. * note that a!=b, so only one of them can be NULL
  2096. */
  2097. if (a == NULL || b == NULL)
  2098. return false;
  2099. /*
  2100. * are they the same type of nodes?
  2101. */
  2102. if (nodeTag(a) != nodeTag(b))
  2103. return false;
  2104. switch (nodeTag(a))
  2105. {
  2106. /*
  2107. * PRIMITIVE NODES
  2108. */
  2109. case T_Alias:
  2110. retval = _equalAlias(a, b);
  2111. break;
  2112. case T_RangeVar:
  2113. retval = _equalRangeVar(a, b);
  2114. break;
  2115. case T_IntoClause:
  2116. retval = _equalIntoClause(a, b);
  2117. break;
  2118. case T_Var:
  2119. retval = _equalVar(a, b);
  2120. break;
  2121. case T_Const:
  2122. retval = _equalConst(a, b);
  2123. break;
  2124. case T_Param:
  2125. retval = _equalParam(a, b);
  2126. break;
  2127. case T_Aggref:
  2128. retval = _equalAggref(a, b);
  2129. break;
  2130. case T_WindowFunc:
  2131. retval = _equalWindowFunc(a, b);
  2132. break;
  2133. case T_ArrayRef:
  2134. retval = _equalArrayRef(a, b);
  2135. break;
  2136. case T_FuncExpr:
  2137. retval = _equalFuncExpr(a, b);
  2138. break;
  2139. case T_NamedArgExpr:
  2140. retval = _equalNamedArgExpr(a, b);
  2141. break;
  2142. case T_OpExpr:
  2143. retval = _equalOpExpr(a, b);
  2144. break;
  2145. case T_DistinctExpr:
  2146. retval = _equalDistinctExpr(a, b);
  2147. break;
  2148. case T_NullIfExpr:
  2149. retval = _equalNullIfExpr(a, b);
  2150. break;
  2151. case T_ScalarArrayOpExpr:
  2152. retval = _equalScalarArrayOpExpr(a, b);
  2153. break;
  2154. case T_BoolExpr:
  2155. retval = _equalBoolExpr(a, b);
  2156. break;
  2157. case T_SubLink:
  2158. retval = _equalSubLink(a, b);
  2159. break;
  2160. case T_SubPlan:
  2161. retval = _equalSubPlan(a, b);
  2162. break;
  2163. case T_AlternativeSubPlan:
  2164. retval = _equalAlternativeSubPlan(a, b);
  2165. break;
  2166. case T_FieldSelect:
  2167. retval = _equalFieldSelect(a, b);
  2168. break;
  2169. case T_FieldStore:
  2170. retval = _equalFieldStore(a, b);
  2171. break;
  2172. case T_RelabelType:
  2173. retval = _equalRelabelType(a, b);
  2174. break;
  2175. case T_CoerceViaIO:
  2176. retval = _equalCoerceViaIO(a, b);
  2177. break;
  2178. case T_ArrayCoerceExpr:
  2179. retval = _equalArrayCoerceExpr(a, b);
  2180. break;
  2181. case T_ConvertRowtypeExpr:
  2182. retval = _equalConvertRowtypeExpr(a, b);
  2183. break;
  2184. case T_CollateExpr:
  2185. retval = _equalCollateExpr(a, b);
  2186. break;
  2187. case T_CaseExpr:
  2188. retval = _equalCaseExpr(a, b);
  2189. break;
  2190. case T_CaseWhen:
  2191. retval = _equalCaseWhen(a, b);
  2192. break;
  2193. case T_CaseTestExpr:
  2194. retval = _equalCaseTestExpr(a, b);
  2195. break;
  2196. case T_ArrayExpr:
  2197. retval = _equalArrayExpr(a, b);
  2198. break;
  2199. case T_RowExpr:
  2200. retval = _equalRowExpr(a, b);
  2201. break;
  2202. case T_RowCompareExpr:
  2203. retval = _equalRowCompareExpr(a, b);
  2204. break;
  2205. case T_CoalesceExpr:
  2206. retval = _equalCoalesceExpr(a, b);
  2207. break;
  2208. case T_MinMaxExpr:
  2209. retval = _equalMinMaxExpr(a, b);
  2210. break;
  2211. case T_XmlExpr:
  2212. retval = _equalXmlExpr(a, b);
  2213. break;
  2214. case T_NullTest:
  2215. retval = _equalNullTest(a, b);
  2216. break;
  2217. case T_BooleanTest:
  2218. retval = _equalBooleanTest(a, b);
  2219. break;
  2220. case T_CoerceToDomain:
  2221. retval = _equalCoerceToDomain(a, b);
  2222. break;
  2223. case T_CoerceToDomainValue:
  2224. retval = _equalCoerceToDomainValue(a, b);
  2225. break;
  2226. case T_SetToDefault:
  2227. retval = _equalSetToDefault(a, b);
  2228. break;
  2229. case T_CurrentOfExpr:
  2230. retval = _equalCurrentOfExpr(a, b);
  2231. break;
  2232. case T_TargetEntry:
  2233. retval = _equalTargetEntry(a, b);
  2234. break;
  2235. case T_RangeTblRef:
  2236. retval = _equalRangeTblRef(a, b);
  2237. break;
  2238. case T_FromExpr:
  2239. retval = _equalFromExpr(a, b);
  2240. break;
  2241. case T_JoinExpr:
  2242. retval = _equalJoinExpr(a, b);
  2243. break;
  2244. /*
  2245. * RELATION NODES
  2246. */
  2247. case T_PathKey:
  2248. retval = _equalPathKey(a, b);
  2249. break;
  2250. case T_RestrictInfo:
  2251. retval = _equalRestrictInfo(a, b);
  2252. break;
  2253. case T_PlaceHolderVar:
  2254. retval = _equalPlaceHolderVar(a, b);
  2255. break;
  2256. case T_SpecialJoinInfo:
  2257. retval = _equalSpecialJoinInfo(a, b);
  2258. break;
  2259. case T_LateralJoinInfo:
  2260. retval = _equalLateralJoinInfo(a, b);
  2261. break;
  2262. case T_AppendRelInfo:
  2263. retval = _equalAppendRelInfo(a, b);
  2264. break;
  2265. case T_PlaceHolderInfo:
  2266. retval = _equalPlaceHolderInfo(a, b);
  2267. break;
  2268. case T_List:
  2269. case T_IntList:
  2270. case T_OidList:
  2271. retval = _equalList(a, b);
  2272. break;
  2273. case T_Integer:
  2274. case T_Float:
  2275. case T_String:
  2276. case T_BitString:
  2277. case T_Null:
  2278. retval = _equalValue(a, b);
  2279. break;
  2280. /*
  2281. * PARSE NODES
  2282. */
  2283. case T_Query:
  2284. retval = _equalQuery(a, b);
  2285. break;
  2286. case T_InsertStmt:
  2287. retval = _equalInsertStmt(a, b);
  2288. break;
  2289. case T_DeleteStmt:
  2290. retval = _equalDeleteStmt(a, b);
  2291. break;
  2292. case T_UpdateStmt:
  2293. retval = _equalUpdateStmt(a, b);
  2294. break;
  2295. case T_SelectStmt:
  2296. retval = _equalSelectStmt(a, b);
  2297. break;
  2298. case T_SetOperationStmt:
  2299. retval = _equalSetOperationStmt(a, b);
  2300. break;
  2301. case T_AlterTableStmt:
  2302. retval = _equalAlterTableStmt(a, b);
  2303. break;
  2304. case T_AlterTableCmd:
  2305. retval = _equalAlterTableCmd(a, b);
  2306. break;
  2307. case T_AlterDomainStmt:
  2308. retval = _equalAlterDomainStmt(a, b);
  2309. break;
  2310. case T_GrantStmt:
  2311. retval = _equalGrantStmt(a, b);
  2312. break;
  2313. case T_GrantRoleStmt:
  2314. retval = _equalGrantRoleStmt(a, b);
  2315. break;
  2316. case T_AlterDefaultPrivilegesStmt:
  2317. retval = _equalAlterDefaultPrivilegesStmt(a, b);
  2318. break;
  2319. case T_DeclareCursorStmt:
  2320. retval = _equalDeclareCursorStmt(a, b);
  2321. break;
  2322. case T_ClosePortalStmt:
  2323. retval = _equalClosePortalStmt(a, b);
  2324. break;
  2325. case T_ClusterStmt:
  2326. retval = _equalClusterStmt(a, b);
  2327. break;
  2328. case T_CopyStmt:
  2329. retval = _equalCopyStmt(a, b);
  2330. break;
  2331. case T_CreateStmt:
  2332. retval = _equalCreateStmt(a, b);
  2333. break;
  2334. case T_TableLikeClause:
  2335. retval = _equalTableLikeClause(a, b);
  2336. break;
  2337. case T_DefineStmt:
  2338. retval = _equalDefineStmt(a, b);
  2339. break;
  2340. case T_DropStmt:
  2341. retval = _equalDropStmt(a, b);
  2342. break;
  2343. case T_TruncateStmt:
  2344. retval = _equalTruncateStmt(a, b);
  2345. break;
  2346. case T_CommentStmt:
  2347. retval = _equalCommentStmt(a, b);
  2348. break;
  2349. case T_SecLabelStmt:
  2350. retval = _equalSecLabelStmt(a, b);
  2351. break;
  2352. case T_FetchStmt:
  2353. retval = _equalFetchStmt(a, b);
  2354. break;
  2355. case T_IndexStmt:
  2356. retval = _equalIndexStmt(a, b);
  2357. break;
  2358. case T_CreateFunctionStmt:
  2359. retval = _equalCreateFunctionStmt(a, b);
  2360. break;
  2361. case T_FunctionParameter:
  2362. retval = _equalFunctionParameter(a, b);
  2363. break;
  2364. case T_AlterFunctionStmt:
  2365. retval = _equalAlterFunctionStmt(a, b);
  2366. break;
  2367. case T_DoStmt:
  2368. retval = _equalDoStmt(a, b);
  2369. break;
  2370. case T_RenameStmt:
  2371. retval = _equalRenameStmt(a, b);
  2372. break;
  2373. case T_AlterObjectSchemaStmt:
  2374. retval = _equalAlterObjectSchemaStmt(a, b);
  2375. break;
  2376. case T_AlterOwnerStmt:
  2377. retval = _equalAlterOwnerStmt(a, b);
  2378. break;
  2379. case T_RuleStmt:
  2380. retval = _equalRuleStmt(a, b);
  2381. break;
  2382. case T_NotifyStmt:
  2383. retval = _equalNotifyStmt(a, b);
  2384. break;
  2385. case T_ListenStmt:
  2386. retval = _equalListenStmt(a, b);
  2387. break;
  2388. case T_UnlistenStmt:
  2389. retval = _equalUnlistenStmt(a, b);
  2390. break;
  2391. case T_TransactionStmt:
  2392. retval = _equalTransactionStmt(a, b);
  2393. break;
  2394. case T_CompositeTypeStmt:
  2395. retval = _equalCompositeTypeStmt(a, b);
  2396. break;
  2397. case T_CreateEnumStmt:
  2398. retval = _equalCreateEnumStmt(a, b);
  2399. break;
  2400. case T_CreateRangeStmt:
  2401. retval = _equalCreateRangeStmt(a, b);
  2402. break;
  2403. case T_AlterEnumStmt:
  2404. retval = _equalAlterEnumStmt(a, b);
  2405. break;
  2406. case T_ViewStmt:
  2407. retval = _equalViewStmt(a, b);
  2408. break;
  2409. case T_LoadStmt:
  2410. retval = _equalLoadStmt(a, b);
  2411. break;
  2412. case T_CreateDomainStmt:
  2413. retval = _equalCreateDomainStmt(a, b);
  2414. break;
  2415. case T_CreateOpClassStmt:
  2416. retval = _equalCreateOpClassStmt(a, b);
  2417. break;
  2418. case T_CreateOpClassItem:
  2419. retval = _equalCreateOpClassItem(a, b);
  2420. break;
  2421. case T_CreateOpFamilyStmt:
  2422. retval = _equalCreateOpFamilyStmt(a, b);
  2423. break;
  2424. case T_AlterOpFamilyStmt:
  2425. retval = _equalAlterOpFamilyStmt(a, b);
  2426. break;
  2427. case T_CreatedbStmt:
  2428. retval = _equalCreatedbStmt(a, b);
  2429. break;
  2430. case T_AlterDatabaseStmt:
  2431. retval = _equalAlterDatabaseStmt(a, b);
  2432. break;
  2433. case T_AlterDatabaseSetStmt:
  2434. retval = _equalAlterDatabaseSetStmt(a, b);
  2435. break;
  2436. case T_DropdbStmt:
  2437. retval = _equalDropdbStmt(a, b);
  2438. break;
  2439. case T_VacuumStmt:
  2440. retval = _equalVacuumStmt(a, b);
  2441. break;
  2442. case T_ExplainStmt:
  2443. retval = _equalExplainStmt(a, b);
  2444. break;
  2445. case T_CreateTableAsStmt:
  2446. retval = _equalCreateTableAsStmt(a, b);
  2447. break;
  2448. case T_RefreshMatViewStmt:
  2449. retval = _equalRefreshMatViewStmt(a, b);
  2450. break;
  2451. case T_ReplicaIdentityStmt:
  2452. retval = _equalReplicaIdentityStmt(a, b);
  2453. break;
  2454. case T_AlterSystemStmt:
  2455. retval = _equalAlterSystemStmt(a, b);
  2456. break;
  2457. case T_CreateSeqStmt:
  2458. retval = _equalCreateSeqStmt(a, b);
  2459. break;
  2460. case T_AlterSeqStmt:
  2461. retval = _equalAlterSeqStmt(a, b);
  2462. break;
  2463. case T_VariableSetStmt:
  2464. retval = _equalVariableSetStmt(a, b);
  2465. break;
  2466. case T_VariableShowStmt:
  2467. retval = _equalVariableShowStmt(a, b);
  2468. break;
  2469. case T_DiscardStmt:
  2470. retval = _equalDiscardStmt(a, b);
  2471. break;
  2472. case T_CreateTableSpaceStmt:
  2473. retval = _equalCreateTableSpaceStmt(a, b);
  2474. break;
  2475. case T_DropTableSpaceStmt:
  2476. retval = _equalDropTableSpaceStmt(a, b);
  2477. break;
  2478. case T_AlterTableSpaceOptionsStmt:
  2479. retval = _equalAlterTableSpaceOptionsStmt(a, b);
  2480. break;
  2481. case T_AlterTableSpaceMoveStmt:
  2482. retval = _equalAlterTableSpaceMoveStmt(a, b);
  2483. break;
  2484. case T_CreateExtensionStmt:
  2485. retval = _equalCreateExtensionStmt(a, b);
  2486. break;
  2487. case T_AlterExtensionStmt:
  2488. retval = _equalAlterExtensionStmt(a, b);
  2489. break;
  2490. case T_AlterExtensionContentsStmt:
  2491. retval = _equalAlterExtensionContentsStmt(a, b);
  2492. break;
  2493. case T_CreateFdwStmt:
  2494. retval = _equalCreateFdwStmt(a, b);
  2495. break;
  2496. case T_AlterFdwStmt:
  2497. retval = _equalAlterFdwStmt(a, b);
  2498. break;
  2499. case T_CreateForeignServerStmt:
  2500. retval = _equalCreateForeignServerStmt(a, b);
  2501. break;
  2502. case T_AlterForeignServerStmt:
  2503. retval = _equalAlterForeignServerStmt(a, b);
  2504. break;
  2505. case T_CreateUserMappingStmt:
  2506. retval = _equalCreateUserMappingStmt(a, b);
  2507. break;
  2508. case T_AlterUserMappingStmt:
  2509. retval = _equalAlterUserMappingStmt(a, b);
  2510. break;
  2511. case T_DropUserMappingStmt:
  2512. retval = _equalDropUserMappingStmt(a, b);
  2513. break;
  2514. case T_CreateForeignTableStmt:
  2515. retval = _equalCreateForeignTableStmt(a, b);
  2516. break;
  2517. case T_CreateTrigStmt:
  2518. retval = _equalCreateTrigStmt(a, b);
  2519. break;
  2520. case T_CreateEventTrigStmt:
  2521. retval = _equalCreateEventTrigStmt(a, b);
  2522. break;
  2523. case T_AlterEventTrigStmt:
  2524. retval = _equalAlterEventTrigStmt(a, b);
  2525. break;
  2526. case T_CreatePLangStmt:
  2527. retval = _equalCreatePLangStmt(a, b);
  2528. break;
  2529. case T_CreateRoleStmt:
  2530. retval = _equalCreateRoleStmt(a, b);
  2531. break;
  2532. case T_AlterRoleStmt:
  2533. retval = _equalAlterRoleStmt(a, b);
  2534. break;
  2535. case T_AlterRoleSetStmt:
  2536. retval = _equalAlterRoleSetStmt(a, b);
  2537. break;
  2538. case T_DropRoleStmt:
  2539. retval = _equalDropRoleStmt(a, b);
  2540. break;
  2541. case T_LockStmt:
  2542. retval = _equalLockStmt(a, b);
  2543. break;
  2544. case T_ConstraintsSetStmt:
  2545. retval = _equalConstraintsSetStmt(a, b);
  2546. break;
  2547. case T_ReindexStmt:
  2548. retval = _equalReindexStmt(a, b);
  2549. break;
  2550. case T_CheckPointStmt:
  2551. retval = true;
  2552. break;
  2553. case T_CreateSchemaStmt:
  2554. retval = _equalCreateSchemaStmt(a, b);
  2555. break;
  2556. case T_CreateConversionStmt:
  2557. retval = _equalCreateConversionStmt(a, b);
  2558. break;
  2559. case T_CreateCastStmt:
  2560. retval = _equalCreateCastStmt(a, b);
  2561. break;
  2562. case T_PrepareStmt:
  2563. retval = _equalPrepareStmt(a, b);
  2564. break;
  2565. case T_ExecuteStmt:
  2566. retval = _equalExecuteStmt(a, b);
  2567. break;
  2568. case T_DeallocateStmt:
  2569. retval = _equalDeallocateStmt(a, b);
  2570. break;
  2571. case T_DropOwnedStmt:
  2572. retval = _equalDropOwnedStmt(a, b);
  2573. break;
  2574. case T_ReassignOwnedStmt:
  2575. retval = _equalReassignOwnedStmt(a, b);
  2576. break;
  2577. case T_AlterTSDictionaryStmt:
  2578. retval = _equalAlterTSDictionaryStmt(a, b);
  2579. break;
  2580. case T_AlterTSConfigurationStmt:
  2581. retval = _equalAlterTSConfigurationStmt(a, b);
  2582. break;
  2583. case T_A_Expr:
  2584. retval = _equalAExpr(a, b);
  2585. break;
  2586. case T_ColumnRef:
  2587. retval = _equalColumnRef(a, b);
  2588. break;
  2589. case T_ParamRef:
  2590. retval = _equalParamRef(a, b);
  2591. break;
  2592. case T_A_Const:
  2593. retval = _equalAConst(a, b);
  2594. break;
  2595. case T_FuncCall:
  2596. retval = _equalFuncCall(a, b);
  2597. break;
  2598. case T_A_Star:
  2599. retval = _equalAStar(a, b);
  2600. break;
  2601. case T_A_Indices:
  2602. retval = _equalAIndices(a, b);
  2603. break;
  2604. case T_A_Indirection:
  2605. retval = _equalA_Indirection(a, b);
  2606. break;
  2607. case T_A_ArrayExpr:
  2608. retval = _equalA_ArrayExpr(a, b);
  2609. break;
  2610. case T_ResTarget:
  2611. retval = _equalResTarget(a, b);
  2612. break;
  2613. case T_TypeCast:
  2614. retval = _equalTypeCast(a, b);
  2615. break;
  2616. case T_CollateClause:
  2617. retval = _equalCollateClause(a, b);
  2618. break;
  2619. case T_SortBy:
  2620. retval = _equalSortBy(a, b);
  2621. break;
  2622. case T_WindowDef:
  2623. retval = _equalWindowDef(a, b);
  2624. break;
  2625. case T_RangeSubselect:
  2626. retval = _equalRangeSubselect(a, b);
  2627. break;
  2628. case T_RangeFunction:
  2629. retval = _equalRangeFunction(a, b);
  2630. break;
  2631. case T_TypeName:
  2632. retval = _equalTypeName(a, b);
  2633. break;
  2634. case T_IndexElem:
  2635. retval = _equalIndexElem(a, b);
  2636. break;
  2637. case T_ColumnDef:
  2638. retval = _equalColumnDef(a, b);
  2639. break;
  2640. case T_Constraint:
  2641. retval = _equalConstraint(a, b);
  2642. break;
  2643. case T_DefElem:
  2644. retval = _equalDefElem(a, b);
  2645. break;
  2646. case T_LockingClause:
  2647. retval = _equalLockingClause(a, b);
  2648. break;
  2649. case T_RangeTblEntry:
  2650. retval = _equalRangeTblEntry(a, b);
  2651. break;
  2652. case T_RangeTblFunction:
  2653. retval = _equalRangeTblFunction(a, b);
  2654. break;
  2655. case T_WithCheckOption:
  2656. retval = _equalWithCheckOption(a, b);
  2657. break;
  2658. case T_SortGroupClause:
  2659. retval = _equalSortGroupClause(a, b);
  2660. break;
  2661. case T_WindowClause:
  2662. retval = _equalWindowClause(a, b);
  2663. break;
  2664. case T_RowMarkClause:
  2665. retval = _equalRowMarkClause(a, b);
  2666. break;
  2667. case T_WithClause:
  2668. retval = _equalWithClause(a, b);
  2669. break;
  2670. case T_CommonTableExpr:
  2671. retval = _equalCommonTableExpr(a, b);
  2672. break;
  2673. case T_PrivGrantee:
  2674. retval = _equalPrivGrantee(a, b);
  2675. break;
  2676. case T_FuncWithArgs:
  2677. retval = _equalFuncWithArgs(a, b);
  2678. break;
  2679. case T_AccessPriv:
  2680. retval = _equalAccessPriv(a, b);
  2681. break;
  2682. case T_XmlSerialize:
  2683. retval = _equalXmlSerialize(a, b);
  2684. break;
  2685. default:
  2686. elog(ERROR, "unrecognized node type: %d",
  2687. (int) nodeTag(a));
  2688. retval = false; /* keep compiler quiet */
  2689. break;
  2690. }
  2691. return retval;
  2692. }