PageRenderTime 53ms CodeModel.GetById 16ms 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

Large files files are truncated, but you can click here to view the full file

  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

Large files files are truncated, but you can click here to view the full file