pg_query 4.2.2 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (486) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/README.md +6 -8
  4. data/Rakefile +3 -3
  5. data/ext/pg_query/extconf.rb +1 -3
  6. data/ext/pg_query/include/access/amapi.h +3 -1
  7. data/ext/pg_query/include/access/attmap.h +5 -3
  8. data/ext/pg_query/include/access/attnum.h +1 -1
  9. data/ext/pg_query/include/access/clog.h +1 -1
  10. data/ext/pg_query/include/access/commit_ts.h +1 -1
  11. data/ext/pg_query/include/access/detoast.h +1 -1
  12. data/ext/pg_query/include/access/genam.h +7 -5
  13. data/ext/pg_query/include/access/gin.h +16 -3
  14. data/ext/pg_query/include/access/htup.h +1 -1
  15. data/ext/pg_query/include/access/htup_details.h +6 -2
  16. data/ext/pg_query/include/access/itup.h +61 -58
  17. data/ext/pg_query/include/access/parallel.h +2 -2
  18. data/ext/pg_query/include/access/printtup.h +1 -1
  19. data/ext/pg_query/include/access/relation.h +1 -1
  20. data/ext/pg_query/include/access/relscan.h +1 -1
  21. data/ext/pg_query/include/access/rmgrlist.h +2 -2
  22. data/ext/pg_query/include/access/sdir.h +12 -3
  23. data/ext/pg_query/include/access/skey.h +1 -1
  24. data/ext/pg_query/include/access/stratnum.h +1 -1
  25. data/ext/pg_query/include/access/sysattr.h +1 -1
  26. data/ext/pg_query/include/access/table.h +1 -1
  27. data/ext/pg_query/include/access/tableam.h +68 -45
  28. data/ext/pg_query/include/access/toast_compression.h +1 -1
  29. data/ext/pg_query/include/access/transam.h +1 -1
  30. data/ext/pg_query/include/access/tsmapi.h +82 -0
  31. data/ext/pg_query/include/access/tupconvert.h +5 -2
  32. data/ext/pg_query/include/access/tupdesc.h +2 -2
  33. data/ext/pg_query/include/access/tupmacs.h +58 -98
  34. data/ext/pg_query/include/access/twophase.h +2 -2
  35. data/ext/pg_query/include/access/xact.h +25 -18
  36. data/ext/pg_query/include/access/xlog.h +15 -16
  37. data/ext/pg_query/include/access/xlog_internal.h +100 -62
  38. data/ext/pg_query/include/access/xlogbackup.h +41 -0
  39. data/ext/pg_query/include/access/xlogdefs.h +6 -25
  40. data/ext/pg_query/include/access/xlogprefetcher.h +1 -1
  41. data/ext/pg_query/include/access/xlogreader.h +7 -6
  42. data/ext/pg_query/include/access/xlogrecord.h +17 -5
  43. data/ext/pg_query/include/access/xlogrecovery.h +4 -3
  44. data/ext/pg_query/include/archive/archive_module.h +59 -0
  45. data/ext/pg_query/include/c.h +144 -156
  46. data/ext/pg_query/include/catalog/catalog.h +4 -3
  47. data/ext/pg_query/include/catalog/catversion.h +6 -2
  48. data/ext/pg_query/include/catalog/dependency.h +5 -4
  49. data/ext/pg_query/include/catalog/genbki.h +7 -6
  50. data/ext/pg_query/include/catalog/index.h +4 -4
  51. data/ext/pg_query/include/catalog/indexing.h +1 -1
  52. data/ext/pg_query/include/catalog/namespace.h +2 -2
  53. data/ext/pg_query/include/catalog/objectaccess.h +10 -8
  54. data/ext/pg_query/include/catalog/objectaddress.h +3 -3
  55. data/ext/pg_query/include/catalog/pg_aggregate.h +1 -1
  56. data/ext/pg_query/include/catalog/pg_aggregate_d.h +1 -1
  57. data/ext/pg_query/include/catalog/pg_am.h +1 -1
  58. data/ext/pg_query/include/catalog/pg_am_d.h +1 -1
  59. data/ext/pg_query/include/catalog/pg_attribute.h +19 -17
  60. data/ext/pg_query/include/catalog/pg_attribute_d.h +19 -19
  61. data/ext/pg_query/include/catalog/pg_authid.h +1 -1
  62. data/ext/pg_query/include/catalog/pg_authid_d.h +3 -1
  63. data/ext/pg_query/include/catalog/pg_class.h +1 -1
  64. data/ext/pg_query/include/catalog/pg_class_d.h +1 -1
  65. data/ext/pg_query/include/catalog/pg_collation.h +3 -1
  66. data/ext/pg_query/include/catalog/pg_collation_d.h +4 -3
  67. data/ext/pg_query/include/catalog/pg_constraint.h +2 -2
  68. data/ext/pg_query/include/catalog/pg_constraint_d.h +1 -1
  69. data/ext/pg_query/include/catalog/pg_control.h +9 -1
  70. data/ext/pg_query/include/catalog/pg_conversion.h +2 -2
  71. data/ext/pg_query/include/catalog/pg_conversion_d.h +1 -1
  72. data/ext/pg_query/include/catalog/pg_database.h +124 -0
  73. data/ext/pg_query/include/catalog/pg_database_d.h +52 -0
  74. data/ext/pg_query/include/catalog/pg_depend.h +1 -1
  75. data/ext/pg_query/include/catalog/pg_depend_d.h +1 -1
  76. data/ext/pg_query/include/catalog/pg_event_trigger.h +1 -1
  77. data/ext/pg_query/include/catalog/pg_event_trigger_d.h +1 -1
  78. data/ext/pg_query/include/catalog/pg_index.h +1 -1
  79. data/ext/pg_query/include/catalog/pg_index_d.h +1 -1
  80. data/ext/pg_query/include/catalog/pg_language.h +1 -1
  81. data/ext/pg_query/include/catalog/pg_language_d.h +1 -1
  82. data/ext/pg_query/include/catalog/pg_namespace.h +1 -1
  83. data/ext/pg_query/include/catalog/pg_namespace_d.h +1 -1
  84. data/ext/pg_query/include/catalog/pg_opclass.h +1 -1
  85. data/ext/pg_query/include/catalog/pg_opclass_d.h +1 -1
  86. data/ext/pg_query/include/catalog/pg_operator.h +1 -1
  87. data/ext/pg_query/include/catalog/pg_operator_d.h +1 -1
  88. data/ext/pg_query/include/catalog/pg_opfamily.h +3 -2
  89. data/ext/pg_query/include/catalog/pg_opfamily_d.h +4 -2
  90. data/ext/pg_query/include/catalog/pg_partitioned_table.h +1 -1
  91. data/ext/pg_query/include/catalog/pg_partitioned_table_d.h +1 -1
  92. data/ext/pg_query/include/catalog/pg_proc.h +1 -1
  93. data/ext/pg_query/include/catalog/pg_proc_d.h +1 -1
  94. data/ext/pg_query/include/catalog/pg_publication.h +2 -5
  95. data/ext/pg_query/include/catalog/pg_publication_d.h +1 -1
  96. data/ext/pg_query/include/catalog/pg_replication_origin.h +1 -1
  97. data/ext/pg_query/include/catalog/pg_replication_origin_d.h +1 -1
  98. data/ext/pg_query/include/catalog/pg_statistic.h +1 -1
  99. data/ext/pg_query/include/catalog/pg_statistic_d.h +1 -1
  100. data/ext/pg_query/include/catalog/pg_statistic_ext.h +1 -1
  101. data/ext/pg_query/include/catalog/pg_statistic_ext_d.h +1 -1
  102. data/ext/pg_query/include/catalog/pg_transform.h +1 -1
  103. data/ext/pg_query/include/catalog/pg_transform_d.h +1 -1
  104. data/ext/pg_query/include/catalog/pg_trigger.h +1 -1
  105. data/ext/pg_query/include/catalog/pg_trigger_d.h +1 -1
  106. data/ext/pg_query/include/catalog/pg_ts_config.h +1 -1
  107. data/ext/pg_query/include/catalog/pg_ts_config_d.h +1 -1
  108. data/ext/pg_query/include/catalog/pg_ts_dict.h +1 -1
  109. data/ext/pg_query/include/catalog/pg_ts_dict_d.h +1 -1
  110. data/ext/pg_query/include/catalog/pg_ts_parser.h +1 -1
  111. data/ext/pg_query/include/catalog/pg_ts_parser_d.h +1 -1
  112. data/ext/pg_query/include/catalog/pg_ts_template.h +1 -1
  113. data/ext/pg_query/include/catalog/pg_ts_template_d.h +1 -1
  114. data/ext/pg_query/include/catalog/pg_type.h +1 -1
  115. data/ext/pg_query/include/catalog/pg_type_d.h +1 -1
  116. data/ext/pg_query/include/catalog/storage.h +6 -6
  117. data/ext/pg_query/include/commands/async.h +1 -1
  118. data/ext/pg_query/include/commands/dbcommands.h +2 -1
  119. data/ext/pg_query/include/commands/defrem.h +2 -1
  120. data/ext/pg_query/include/commands/event_trigger.h +1 -1
  121. data/ext/pg_query/include/commands/explain.h +3 -1
  122. data/ext/pg_query/include/commands/prepare.h +1 -1
  123. data/ext/pg_query/include/commands/tablespace.h +4 -4
  124. data/ext/pg_query/include/commands/trigger.h +15 -14
  125. data/ext/pg_query/include/commands/user.h +9 -3
  126. data/ext/pg_query/include/commands/vacuum.h +60 -14
  127. data/ext/pg_query/include/common/cryptohash.h +39 -0
  128. data/ext/pg_query/include/common/file_perm.h +1 -1
  129. data/ext/pg_query/include/common/hashfn.h +1 -1
  130. data/ext/pg_query/include/common/int.h +437 -0
  131. data/ext/pg_query/include/common/ip.h +4 -2
  132. data/ext/pg_query/include/common/keywords.h +1 -1
  133. data/ext/pg_query/include/common/kwlookup.h +2 -2
  134. data/ext/pg_query/include/common/pg_prng.h +3 -2
  135. data/ext/pg_query/include/common/relpath.h +20 -13
  136. data/ext/pg_query/include/common/scram-common.h +70 -0
  137. data/ext/pg_query/include/common/sha2.h +32 -0
  138. data/ext/pg_query/include/common/string.h +5 -3
  139. data/ext/pg_query/include/common/unicode_east_asian_fw_table.h +10 -10
  140. data/ext/pg_query/include/common/{unicode_combining_table.h → unicode_nonspacing_table.h} +31 -13
  141. data/ext/pg_query/include/copyfuncs.funcs.c +5013 -0
  142. data/ext/pg_query/include/copyfuncs.switch.c +938 -0
  143. data/ext/pg_query/include/datatype/timestamp.h +11 -4
  144. data/ext/pg_query/include/equalfuncs.funcs.c +3097 -0
  145. data/ext/pg_query/include/equalfuncs.switch.c +785 -0
  146. data/ext/pg_query/include/executor/execdesc.h +1 -1
  147. data/ext/pg_query/include/executor/executor.h +34 -17
  148. data/ext/pg_query/include/executor/functions.h +1 -1
  149. data/ext/pg_query/include/executor/instrument.h +1 -1
  150. data/ext/pg_query/include/executor/spi.h +2 -2
  151. data/ext/pg_query/include/executor/tablefunc.h +1 -1
  152. data/ext/pg_query/include/executor/tuptable.h +18 -11
  153. data/ext/pg_query/include/fmgr.h +21 -2
  154. data/ext/pg_query/include/foreign/fdwapi.h +294 -0
  155. data/ext/pg_query/include/funcapi.h +12 -12
  156. data/ext/pg_query/include/gram.h +1127 -0
  157. data/ext/pg_query/include/{parser/gramparse.h → gramparse.h} +4 -4
  158. data/ext/pg_query/include/jit/jit.h +2 -2
  159. data/ext/pg_query/include/kwlist_d.h +534 -510
  160. data/ext/pg_query/include/lib/dshash.h +4 -1
  161. data/ext/pg_query/include/lib/ilist.h +435 -22
  162. data/ext/pg_query/include/lib/pairingheap.h +1 -1
  163. data/ext/pg_query/include/lib/simplehash.h +9 -9
  164. data/ext/pg_query/include/lib/sort_template.h +1 -1
  165. data/ext/pg_query/include/lib/stringinfo.h +3 -3
  166. data/ext/pg_query/include/libpq/auth.h +8 -2
  167. data/ext/pg_query/include/libpq/crypt.h +1 -1
  168. data/ext/pg_query/include/libpq/hba.h +24 -17
  169. data/ext/pg_query/include/libpq/libpq-be.h +36 -25
  170. data/ext/pg_query/include/libpq/libpq.h +1 -1
  171. data/ext/pg_query/include/libpq/pqcomm.h +10 -41
  172. data/ext/pg_query/include/libpq/pqformat.h +2 -2
  173. data/ext/pg_query/include/libpq/pqsignal.h +22 -10
  174. data/ext/pg_query/include/libpq/sasl.h +136 -0
  175. data/ext/pg_query/include/libpq/scram.h +37 -0
  176. data/ext/pg_query/include/mb/pg_wchar.h +35 -18
  177. data/ext/pg_query/include/mb/stringinfo_mb.h +1 -1
  178. data/ext/pg_query/include/miscadmin.h +26 -14
  179. data/ext/pg_query/include/nodes/bitmapset.h +11 -7
  180. data/ext/pg_query/include/nodes/execnodes.h +83 -30
  181. data/ext/pg_query/include/nodes/extensible.h +5 -3
  182. data/ext/pg_query/include/nodes/lockoptions.h +1 -1
  183. data/ext/pg_query/include/nodes/makefuncs.h +14 -2
  184. data/ext/pg_query/include/nodes/memnodes.h +7 -4
  185. data/ext/pg_query/include/nodes/miscnodes.h +56 -0
  186. data/ext/pg_query/include/nodes/nodeFuncs.h +89 -29
  187. data/ext/pg_query/include/nodes/nodes.h +95 -510
  188. data/ext/pg_query/include/nodes/nodetags.h +471 -0
  189. data/ext/pg_query/include/nodes/params.h +3 -3
  190. data/ext/pg_query/include/nodes/parsenodes.h +377 -139
  191. data/ext/pg_query/include/nodes/pathnodes.h +1090 -440
  192. data/ext/pg_query/include/nodes/pg_list.h +30 -7
  193. data/ext/pg_query/include/nodes/plannodes.h +367 -124
  194. data/ext/pg_query/include/nodes/primnodes.h +670 -222
  195. data/ext/pg_query/include/nodes/print.h +1 -1
  196. data/ext/pg_query/include/{utils → nodes}/queryjumble.h +5 -7
  197. data/ext/pg_query/include/nodes/replnodes.h +111 -0
  198. data/ext/pg_query/include/nodes/supportnodes.h +346 -0
  199. data/ext/pg_query/include/nodes/tidbitmap.h +1 -1
  200. data/ext/pg_query/include/nodes/value.h +12 -2
  201. data/ext/pg_query/include/optimizer/cost.h +6 -4
  202. data/ext/pg_query/include/optimizer/geqo.h +1 -1
  203. data/ext/pg_query/include/optimizer/geqo_gene.h +1 -1
  204. data/ext/pg_query/include/optimizer/optimizer.h +8 -8
  205. data/ext/pg_query/include/optimizer/paths.h +16 -7
  206. data/ext/pg_query/include/optimizer/planmain.h +3 -6
  207. data/ext/pg_query/include/parser/analyze.h +4 -3
  208. data/ext/pg_query/include/parser/kwlist.h +12 -1
  209. data/ext/pg_query/include/parser/parse_agg.h +4 -2
  210. data/ext/pg_query/include/parser/parse_coerce.h +3 -1
  211. data/ext/pg_query/include/parser/parse_expr.h +1 -1
  212. data/ext/pg_query/include/parser/parse_func.h +1 -1
  213. data/ext/pg_query/include/parser/parse_node.h +22 -4
  214. data/ext/pg_query/include/parser/parse_oper.h +3 -3
  215. data/ext/pg_query/include/parser/parse_relation.h +8 -3
  216. data/ext/pg_query/include/parser/parse_type.h +4 -3
  217. data/ext/pg_query/include/parser/parser.h +1 -1
  218. data/ext/pg_query/include/parser/parsetree.h +1 -1
  219. data/ext/pg_query/include/parser/scanner.h +2 -2
  220. data/ext/pg_query/include/parser/scansup.h +1 -1
  221. data/ext/pg_query/include/partitioning/partdefs.h +1 -1
  222. data/ext/pg_query/include/pg_config.h +23 -217
  223. data/ext/pg_query/include/pg_config_manual.h +8 -46
  224. data/ext/pg_query/include/pg_getopt.h +1 -1
  225. data/ext/pg_query/include/pg_query.h +27 -3
  226. data/ext/pg_query/include/pg_query_enum_defs.c +311 -149
  227. data/ext/pg_query/include/pg_query_fingerprint_conds.c +545 -489
  228. data/ext/pg_query/include/pg_query_fingerprint_defs.c +5092 -4432
  229. data/ext/pg_query/include/pg_query_outfuncs_conds.c +385 -343
  230. data/ext/pg_query/include/pg_query_outfuncs_defs.c +1294 -1161
  231. data/ext/pg_query/include/pg_query_readfuncs_conds.c +137 -123
  232. data/ext/pg_query/include/pg_query_readfuncs_defs.c +1657 -1496
  233. data/ext/pg_query/include/pg_trace.h +1 -1
  234. data/ext/pg_query/include/pgstat.h +172 -93
  235. data/ext/pg_query/include/pgtime.h +3 -3
  236. data/ext/pg_query/include/pl_gram.h +64 -62
  237. data/ext/pg_query/include/pl_reserved_kwlist.h +1 -1
  238. data/ext/pg_query/include/pl_reserved_kwlist_d.h +1 -1
  239. data/ext/pg_query/include/pl_unreserved_kwlist.h +2 -1
  240. data/ext/pg_query/include/pl_unreserved_kwlist_d.h +48 -46
  241. data/ext/pg_query/include/plpgsql.h +17 -22
  242. data/ext/pg_query/include/port/atomics/arch-arm.h +3 -3
  243. data/ext/pg_query/include/port/atomics/arch-ppc.h +21 -21
  244. data/ext/pg_query/include/port/atomics/arch-x86.h +2 -2
  245. data/ext/pg_query/include/port/atomics/fallback.h +3 -3
  246. data/ext/pg_query/include/port/atomics/generic-gcc.h +1 -1
  247. data/ext/pg_query/include/port/atomics/generic.h +1 -1
  248. data/ext/pg_query/include/port/atomics.h +2 -7
  249. data/ext/pg_query/include/port/pg_bitutils.h +62 -25
  250. data/ext/pg_query/include/port/pg_bswap.h +1 -1
  251. data/ext/pg_query/include/port/pg_crc32c.h +1 -1
  252. data/ext/pg_query/include/port/simd.h +375 -0
  253. data/ext/pg_query/include/port.h +42 -75
  254. data/ext/pg_query/include/portability/instr_time.h +81 -140
  255. data/ext/pg_query/include/postgres.h +205 -434
  256. data/ext/pg_query/include/postgres_ext.h +0 -1
  257. data/ext/pg_query/include/postmaster/autovacuum.h +1 -4
  258. data/ext/pg_query/include/postmaster/auxprocess.h +1 -1
  259. data/ext/pg_query/include/postmaster/bgworker.h +2 -2
  260. data/ext/pg_query/include/postmaster/bgworker_internals.h +1 -1
  261. data/ext/pg_query/include/postmaster/bgwriter.h +2 -2
  262. data/ext/pg_query/include/postmaster/fork_process.h +1 -1
  263. data/ext/pg_query/include/postmaster/interrupt.h +1 -1
  264. data/ext/pg_query/include/postmaster/pgarch.h +1 -38
  265. data/ext/pg_query/include/postmaster/postmaster.h +5 -2
  266. data/ext/pg_query/include/postmaster/startup.h +3 -1
  267. data/ext/pg_query/include/postmaster/syslogger.h +2 -2
  268. data/ext/pg_query/include/postmaster/walwriter.h +3 -1
  269. data/ext/pg_query/include/protobuf/pg_query.pb-c.h +6186 -5585
  270. data/ext/pg_query/include/protobuf/pg_query.pb.h +112443 -91222
  271. data/ext/pg_query/include/regex/regex.h +9 -6
  272. data/ext/pg_query/include/replication/logicallauncher.h +6 -1
  273. data/ext/pg_query/include/replication/logicalproto.h +30 -10
  274. data/ext/pg_query/include/replication/logicalworker.h +14 -1
  275. data/ext/pg_query/include/replication/origin.h +4 -4
  276. data/ext/pg_query/include/replication/reorderbuffer.h +113 -45
  277. data/ext/pg_query/include/replication/slot.h +25 -6
  278. data/ext/pg_query/include/replication/syncrep.h +2 -8
  279. data/ext/pg_query/include/replication/walreceiver.h +15 -9
  280. data/ext/pg_query/include/replication/walsender.h +13 -13
  281. data/ext/pg_query/include/rewrite/prs2lock.h +1 -1
  282. data/ext/pg_query/include/rewrite/rewriteHandler.h +1 -4
  283. data/ext/pg_query/include/rewrite/rewriteManip.h +11 -2
  284. data/ext/pg_query/include/rewrite/rewriteSupport.h +1 -1
  285. data/ext/pg_query/include/src_backend_nodes_copyfuncs.funcs.c +5321 -0
  286. data/ext/pg_query/include/src_backend_nodes_equalfuncs.funcs.c +3354 -0
  287. data/ext/pg_query/include/storage/backendid.h +1 -1
  288. data/ext/pg_query/include/storage/block.h +24 -31
  289. data/ext/pg_query/include/storage/buf.h +1 -1
  290. data/ext/pg_query/include/storage/bufmgr.h +183 -87
  291. data/ext/pg_query/include/storage/bufpage.h +146 -93
  292. data/ext/pg_query/include/storage/condition_variable.h +2 -2
  293. data/ext/pg_query/include/storage/dsm.h +3 -6
  294. data/ext/pg_query/include/storage/dsm_impl.h +4 -1
  295. data/ext/pg_query/include/storage/fd.h +24 -20
  296. data/ext/pg_query/include/storage/fileset.h +1 -1
  297. data/ext/pg_query/include/storage/ipc.h +1 -1
  298. data/ext/pg_query/include/storage/item.h +1 -1
  299. data/ext/pg_query/include/storage/itemid.h +1 -1
  300. data/ext/pg_query/include/storage/itemptr.h +94 -57
  301. data/ext/pg_query/include/storage/large_object.h +1 -1
  302. data/ext/pg_query/include/storage/latch.h +9 -1
  303. data/ext/pg_query/include/storage/lmgr.h +6 -1
  304. data/ext/pg_query/include/storage/lock.h +21 -13
  305. data/ext/pg_query/include/storage/lockdefs.h +3 -3
  306. data/ext/pg_query/include/storage/lwlock.h +16 -2
  307. data/ext/pg_query/include/storage/off.h +1 -1
  308. data/ext/pg_query/include/storage/pg_sema.h +1 -1
  309. data/ext/pg_query/include/storage/pg_shmem.h +1 -1
  310. data/ext/pg_query/include/storage/pmsignal.h +1 -1
  311. data/ext/pg_query/include/storage/predicate.h +2 -2
  312. data/ext/pg_query/include/storage/proc.h +22 -17
  313. data/ext/pg_query/include/storage/procarray.h +3 -2
  314. data/ext/pg_query/include/storage/proclist_types.h +1 -1
  315. data/ext/pg_query/include/storage/procsignal.h +3 -1
  316. data/ext/pg_query/include/storage/relfilelocator.h +99 -0
  317. data/ext/pg_query/include/storage/s_lock.h +66 -309
  318. data/ext/pg_query/include/storage/sharedfileset.h +1 -1
  319. data/ext/pg_query/include/storage/shm_mq.h +1 -1
  320. data/ext/pg_query/include/storage/shm_toc.h +1 -1
  321. data/ext/pg_query/include/storage/shmem.h +1 -23
  322. data/ext/pg_query/include/storage/sinval.h +3 -3
  323. data/ext/pg_query/include/storage/sinvaladt.h +4 -2
  324. data/ext/pg_query/include/storage/smgr.h +12 -10
  325. data/ext/pg_query/include/storage/spin.h +1 -1
  326. data/ext/pg_query/include/storage/standby.h +9 -8
  327. data/ext/pg_query/include/storage/standbydefs.h +1 -1
  328. data/ext/pg_query/include/storage/sync.h +3 -3
  329. data/ext/pg_query/include/tcop/cmdtag.h +7 -2
  330. data/ext/pg_query/include/tcop/cmdtaglist.h +1 -1
  331. data/ext/pg_query/include/tcop/deparse_utility.h +1 -1
  332. data/ext/pg_query/include/tcop/dest.h +1 -3
  333. data/ext/pg_query/include/tcop/fastpath.h +1 -1
  334. data/ext/pg_query/include/tcop/pquery.h +1 -1
  335. data/ext/pg_query/include/tcop/tcopprot.h +1 -4
  336. data/ext/pg_query/include/tcop/utility.h +1 -1
  337. data/ext/pg_query/include/tsearch/ts_cache.h +2 -4
  338. data/ext/pg_query/include/utils/acl.h +26 -81
  339. data/ext/pg_query/include/utils/aclchk_internal.h +1 -1
  340. data/ext/pg_query/include/utils/array.h +19 -1
  341. data/ext/pg_query/include/utils/backend_progress.h +2 -1
  342. data/ext/pg_query/include/utils/backend_status.h +24 -3
  343. data/ext/pg_query/include/utils/builtins.h +14 -5
  344. data/ext/pg_query/include/utils/bytea.h +1 -1
  345. data/ext/pg_query/include/utils/catcache.h +1 -1
  346. data/ext/pg_query/include/utils/date.h +37 -9
  347. data/ext/pg_query/include/utils/datetime.h +41 -21
  348. data/ext/pg_query/include/utils/datum.h +1 -1
  349. data/ext/pg_query/include/utils/dsa.h +5 -1
  350. data/ext/pg_query/include/utils/elog.h +101 -26
  351. data/ext/pg_query/include/utils/expandeddatum.h +14 -3
  352. data/ext/pg_query/include/utils/expandedrecord.h +14 -4
  353. data/ext/pg_query/include/utils/float.h +7 -6
  354. data/ext/pg_query/include/utils/fmgroids.h +54 -1
  355. data/ext/pg_query/include/utils/fmgrprotos.h +45 -3
  356. data/ext/pg_query/include/utils/fmgrtab.h +1 -1
  357. data/ext/pg_query/include/utils/guc.h +55 -82
  358. data/ext/pg_query/include/utils/guc_hooks.h +163 -0
  359. data/ext/pg_query/include/utils/guc_tables.h +49 -3
  360. data/ext/pg_query/include/utils/hsearch.h +1 -1
  361. data/ext/pg_query/include/utils/inval.h +3 -3
  362. data/ext/pg_query/include/utils/logtape.h +77 -0
  363. data/ext/pg_query/include/utils/lsyscache.h +5 -1
  364. data/ext/pg_query/include/utils/memdebug.h +1 -1
  365. data/ext/pg_query/include/utils/memutils.h +5 -49
  366. data/ext/pg_query/include/utils/memutils_internal.h +136 -0
  367. data/ext/pg_query/include/utils/memutils_memorychunk.h +237 -0
  368. data/ext/pg_query/include/utils/numeric.h +20 -5
  369. data/ext/pg_query/include/utils/palloc.h +8 -1
  370. data/ext/pg_query/include/utils/partcache.h +3 -2
  371. data/ext/pg_query/include/utils/pg_locale.h +22 -14
  372. data/ext/pg_query/include/utils/pgstat_internal.h +37 -7
  373. data/ext/pg_query/include/utils/pidfile.h +1 -1
  374. data/ext/pg_query/include/utils/plancache.h +1 -1
  375. data/ext/pg_query/include/utils/portal.h +1 -1
  376. data/ext/pg_query/include/utils/probes.h +6 -6
  377. data/ext/pg_query/include/utils/ps_status.h +23 -1
  378. data/ext/pg_query/include/utils/queryenvironment.h +1 -1
  379. data/ext/pg_query/include/utils/regproc.h +3 -3
  380. data/ext/pg_query/include/utils/rel.h +60 -43
  381. data/ext/pg_query/include/utils/relcache.h +13 -8
  382. data/ext/pg_query/include/utils/reltrigger.h +1 -1
  383. data/ext/pg_query/include/utils/resowner.h +1 -1
  384. data/ext/pg_query/include/utils/ruleutils.h +6 -1
  385. data/ext/pg_query/include/utils/sharedtuplestore.h +1 -1
  386. data/ext/pg_query/include/utils/snapmgr.h +4 -2
  387. data/ext/pg_query/include/utils/snapshot.h +1 -1
  388. data/ext/pg_query/include/utils/sortsupport.h +2 -2
  389. data/ext/pg_query/include/utils/syscache.h +4 -1
  390. data/ext/pg_query/include/utils/timeout.h +1 -1
  391. data/ext/pg_query/include/utils/timestamp.h +41 -11
  392. data/ext/pg_query/include/utils/tuplesort.h +189 -35
  393. data/ext/pg_query/include/utils/tuplestore.h +1 -1
  394. data/ext/pg_query/include/utils/typcache.h +1 -1
  395. data/ext/pg_query/include/utils/varlena.h +13 -1
  396. data/ext/pg_query/include/utils/wait_event.h +9 -4
  397. data/ext/pg_query/include/utils/xml.h +15 -5
  398. data/ext/pg_query/include/varatt.h +358 -0
  399. data/ext/pg_query/pg_query.c +1 -1
  400. data/ext/pg_query/pg_query.pb-c.c +19755 -17757
  401. data/ext/pg_query/pg_query_fingerprint.c +8 -3
  402. data/ext/pg_query/pg_query_fingerprint.h +1 -1
  403. data/ext/pg_query/pg_query_internal.h +1 -1
  404. data/ext/pg_query/pg_query_json_plpgsql.c +1 -0
  405. data/ext/pg_query/pg_query_normalize.c +1 -1
  406. data/ext/pg_query/pg_query_outfuncs_protobuf.c +2 -2
  407. data/ext/pg_query/pg_query_parse.c +46 -4
  408. data/ext/pg_query/pg_query_parse_plpgsql.c +1 -1
  409. data/ext/pg_query/pg_query_scan.c +1 -1
  410. data/ext/pg_query/pg_query_split.c +2 -2
  411. data/ext/pg_query/postgres_deparse.c +511 -109
  412. data/ext/pg_query/src_backend_catalog_namespace.c +7 -2
  413. data/ext/pg_query/src_backend_catalog_pg_proc.c +1 -1
  414. data/ext/pg_query/src_backend_commands_define.c +1 -1
  415. data/ext/pg_query/src_backend_nodes_bitmapset.c +11 -70
  416. data/ext/pg_query/src_backend_nodes_copyfuncs.c +96 -6202
  417. data/ext/pg_query/src_backend_nodes_equalfuncs.c +95 -4068
  418. data/ext/pg_query/src_backend_nodes_extensible.c +6 -29
  419. data/ext/pg_query/src_backend_nodes_list.c +14 -2
  420. data/ext/pg_query/src_backend_nodes_makefuncs.c +95 -1
  421. data/ext/pg_query/src_backend_nodes_nodeFuncs.c +283 -132
  422. data/ext/pg_query/src_backend_nodes_value.c +1 -1
  423. data/ext/pg_query/src_backend_parser_gram.c +33208 -31806
  424. data/ext/pg_query/src_backend_parser_parser.c +28 -2
  425. data/ext/pg_query/src_backend_parser_scan.c +4318 -3329
  426. data/ext/pg_query/src_backend_parser_scansup.c +1 -1
  427. data/ext/pg_query/src_backend_postmaster_postmaster.c +129 -110
  428. data/ext/pg_query/src_backend_storage_ipc_ipc.c +1 -1
  429. data/ext/pg_query/src_backend_tcop_postgres.c +66 -87
  430. data/ext/pg_query/src_backend_utils_activity_pgstat_database.c +1 -1
  431. data/ext/pg_query/src_backend_utils_adt_datum.c +5 -7
  432. data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +1 -1
  433. data/ext/pg_query/src_backend_utils_adt_format_type.c +1 -1
  434. data/ext/pg_query/src_backend_utils_adt_numutils.c +489 -0
  435. data/ext/pg_query/src_backend_utils_adt_ruleutils.c +79 -5
  436. data/ext/pg_query/src_backend_utils_error_assert.c +4 -7
  437. data/ext/pg_query/src_backend_utils_error_elog.c +354 -97
  438. data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +33 -1
  439. data/ext/pg_query/src_backend_utils_init_globals.c +5 -2
  440. data/ext/pg_query/src_backend_utils_mb_mbutils.c +13 -4
  441. data/ext/pg_query/src_backend_utils_misc_guc_tables.c +494 -0
  442. data/ext/pg_query/src_backend_utils_mmgr_alignedalloc.c +163 -0
  443. data/ext/pg_query/src_backend_utils_mmgr_aset.c +449 -312
  444. data/ext/pg_query/src_backend_utils_mmgr_generation.c +1039 -0
  445. data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +398 -49
  446. data/ext/pg_query/src_backend_utils_mmgr_slab.c +1021 -0
  447. data/ext/pg_query/src_common_encnames.c +4 -1
  448. data/ext/pg_query/src_common_hashfn.c +1 -1
  449. data/ext/pg_query/src_common_keywords.c +1 -1
  450. data/ext/pg_query/src_common_kwlist_d.h +534 -510
  451. data/ext/pg_query/src_common_kwlookup.c +1 -1
  452. data/ext/pg_query/src_common_psprintf.c +1 -1
  453. data/ext/pg_query/src_common_stringinfo.c +4 -4
  454. data/ext/pg_query/src_common_wchar.c +9 -8
  455. data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +1 -1
  456. data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +3 -1
  457. data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +661 -694
  458. data/ext/pg_query/src_pl_plpgsql_src_pl_handler.c +1 -1
  459. data/ext/pg_query/src_pl_plpgsql_src_pl_reserved_kwlist_d.h +1 -1
  460. data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +1 -1
  461. data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +48 -46
  462. data/ext/pg_query/src_port_pg_bitutils.c +1 -1
  463. data/ext/pg_query/src_port_pgstrcasecmp.c +29 -1
  464. data/ext/pg_query/src_port_snprintf.c +3 -7
  465. data/ext/pg_query/src_port_strerror.c +1 -1
  466. data/ext/pg_query/src_port_strnlen.c +1 -1
  467. data/lib/pg_query/pg_query_pb.rb +166 -3191
  468. data/lib/pg_query/treewalker.rb +7 -2
  469. data/lib/pg_query/version.rb +1 -1
  470. metadata +43 -24
  471. data/ext/pg_query/include/catalog/pg_parameter_acl.h +0 -60
  472. data/ext/pg_query/include/catalog/pg_parameter_acl_d.h +0 -34
  473. data/ext/pg_query/include/commands/variable.h +0 -38
  474. data/ext/pg_query/include/getaddrinfo.h +0 -162
  475. data/ext/pg_query/include/parser/gram.h +0 -1101
  476. data/ext/pg_query/include/storage/relfilenode.h +0 -99
  477. data/ext/pg_query/include/utils/dynahash.h +0 -20
  478. data/ext/pg_query/include/utils/pg_lsn.h +0 -29
  479. data/ext/pg_query/include/utils/rls.h +0 -50
  480. data/ext/pg_query/include/utils/tzparser.h +0 -39
  481. data/ext/pg_query/src_backend_storage_lmgr_s_lock.c +0 -371
  482. data/ext/pg_query/src_backend_utils_hash_dynahash.c +0 -1116
  483. data/ext/pg_query/src_backend_utils_misc_guc.c +0 -1993
  484. data/ext/pg_query/src_common_pg_prng.c +0 -152
  485. data/ext/pg_query/src_common_string.c +0 -92
  486. data/ext/pg_query/src_port_pgsleep.c +0 -69
@@ -7,7 +7,7 @@
7
7
  * and join trees.
8
8
  *
9
9
  *
10
- * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
10
+ * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
11
11
  * Portions Copyright (c) 1994, Regents of the University of California
12
12
  *
13
13
  * src/include/nodes/primnodes.h
@@ -63,14 +63,27 @@ typedef enum OnCommitAction
63
63
  typedef struct RangeVar
64
64
  {
65
65
  NodeTag type;
66
- char *catalogname; /* the catalog (database) name, or NULL */
67
- char *schemaname; /* the schema name, or NULL */
68
- char *relname; /* the relation/sequence name */
69
- bool inh; /* expand rel by inheritance? recursively act
70
- * on children? */
71
- char relpersistence; /* see RELPERSISTENCE_* in pg_class.h */
72
- Alias *alias; /* table alias & optional column aliases */
73
- int location; /* token location, or -1 if unknown */
66
+
67
+ /* the catalog (database) name, or NULL */
68
+ char *catalogname;
69
+
70
+ /* the schema name, or NULL */
71
+ char *schemaname;
72
+
73
+ /* the relation/sequence name */
74
+ char *relname;
75
+
76
+ /* expand rel by inheritance? recursively act on children? */
77
+ bool inh;
78
+
79
+ /* see RELPERSISTENCE_* in pg_class.h */
80
+ char relpersistence;
81
+
82
+ /* table alias & optional column aliases */
83
+ Alias *alias;
84
+
85
+ /* token location, or -1 if unknown */
86
+ int location;
74
87
  } RangeVar;
75
88
 
76
89
  /*
@@ -82,19 +95,32 @@ typedef struct RangeVar
82
95
  typedef struct TableFunc
83
96
  {
84
97
  NodeTag type;
85
- List *ns_uris; /* list of namespace URI expressions */
86
- List *ns_names; /* list of namespace names or NULL */
87
- Node *docexpr; /* input document expression */
88
- Node *rowexpr; /* row filter expression */
89
- List *colnames; /* column names (list of String) */
90
- List *coltypes; /* OID list of column type OIDs */
91
- List *coltypmods; /* integer list of column typmods */
92
- List *colcollations; /* OID list of column collation OIDs */
93
- List *colexprs; /* list of column filter expressions */
94
- List *coldefexprs; /* list of column default expressions */
95
- Bitmapset *notnulls; /* nullability flag for each output column */
96
- int ordinalitycol; /* counts from 0; -1 if none specified */
97
- int location; /* token location, or -1 if unknown */
98
+ /* list of namespace URI expressions */
99
+ List *ns_uris pg_node_attr(query_jumble_ignore);
100
+ /* list of namespace names or NULL */
101
+ List *ns_names pg_node_attr(query_jumble_ignore);
102
+ /* input document expression */
103
+ Node *docexpr;
104
+ /* row filter expression */
105
+ Node *rowexpr;
106
+ /* column names (list of String) */
107
+ List *colnames pg_node_attr(query_jumble_ignore);
108
+ /* OID list of column type OIDs */
109
+ List *coltypes pg_node_attr(query_jumble_ignore);
110
+ /* integer list of column typmods */
111
+ List *coltypmods pg_node_attr(query_jumble_ignore);
112
+ /* OID list of column collation OIDs */
113
+ List *colcollations pg_node_attr(query_jumble_ignore);
114
+ /* list of column filter expressions */
115
+ List *colexprs;
116
+ /* list of column default expressions */
117
+ List *coldefexprs pg_node_attr(query_jumble_ignore);
118
+ /* nullability flag for each output column */
119
+ Bitmapset *notnulls pg_node_attr(query_jumble_ignore);
120
+ /* counts from 0; -1 if none specified */
121
+ int ordinalitycol pg_node_attr(query_jumble_ignore);
122
+ /* token location, or -1 if unknown */
123
+ int location;
98
124
  } TableFunc;
99
125
 
100
126
  /*
@@ -102,8 +128,10 @@ typedef struct TableFunc
102
128
  * CREATE MATERIALIZED VIEW
103
129
  *
104
130
  * For CREATE MATERIALIZED VIEW, viewQuery is the parsed-but-not-rewritten
105
- * SELECT Query for the view; otherwise it's NULL. (Although it's actually
106
- * Query*, we declare it as Node* to avoid a forward reference.)
131
+ * SELECT Query for the view; otherwise it's NULL. This is irrelevant in
132
+ * the query jumbling as CreateTableAsStmt already includes a reference to
133
+ * its own Query, so ignore it. (Although it's actually Query*, we declare
134
+ * it as Node* to avoid a forward reference.)
107
135
  */
108
136
  typedef struct IntoClause
109
137
  {
@@ -115,7 +143,8 @@ typedef struct IntoClause
115
143
  List *options; /* options from WITH clause */
116
144
  OnCommitAction onCommit; /* what do we do at COMMIT? */
117
145
  char *tableSpaceName; /* table space to use, or NULL */
118
- Node *viewQuery; /* materialized view's SELECT query */
146
+ /* materialized view's SELECT query */
147
+ Node *viewQuery pg_node_attr(query_jumble_ignore);
119
148
  bool skipData; /* true for WITH NO DATA */
120
149
  } IntoClause;
121
150
 
@@ -135,6 +164,8 @@ typedef struct IntoClause
135
164
  */
136
165
  typedef struct Expr
137
166
  {
167
+ pg_node_attr(abstract)
168
+
138
169
  NodeTag type;
139
170
  } Expr;
140
171
 
@@ -162,6 +193,14 @@ typedef struct Expr
162
193
  * row identity information during UPDATE/DELETE/MERGE. This value should
163
194
  * never be seen outside the planner.
164
195
  *
196
+ * varnullingrels is the set of RT indexes of outer joins that can force
197
+ * the Var's value to null (at the point where it appears in the query).
198
+ * See optimizer/README for discussion of that.
199
+ *
200
+ * varlevelsup is greater than zero in Vars that represent outer references.
201
+ * Note that it affects the meaning of all of varno, varnullingrels, and
202
+ * varnosyn, all of which refer to the range table of that query level.
203
+ *
165
204
  * In the parser, varnosyn and varattnosyn are either identical to
166
205
  * varno/varattno, or they specify the column's position in an aliased JOIN
167
206
  * RTE that hides the semantic referent RTE's refname. This is a syntactic
@@ -186,19 +225,50 @@ typedef struct Expr
186
225
  typedef struct Var
187
226
  {
188
227
  Expr xpr;
189
- int varno; /* index of this var's relation in the range
190
- * table, or INNER_VAR/OUTER_VAR/etc */
191
- AttrNumber varattno; /* attribute number of this var, or zero for
192
- * all attrs ("whole-row Var") */
193
- Oid vartype; /* pg_type OID for the type of this var */
194
- int32 vartypmod; /* pg_attribute typmod value */
195
- Oid varcollid; /* OID of collation, or InvalidOid if none */
196
- Index varlevelsup; /* for subquery variables referencing outer
197
- * relations; 0 in a normal var, >0 means N
198
- * levels up */
199
- Index varnosyn; /* syntactic relation index (0 if unknown) */
200
- AttrNumber varattnosyn; /* syntactic attribute number */
201
- int location; /* token location, or -1 if unknown */
228
+
229
+ /*
230
+ * index of this var's relation in the range table, or
231
+ * INNER_VAR/OUTER_VAR/etc
232
+ */
233
+ int varno;
234
+
235
+ /*
236
+ * attribute number of this var, or zero for all attrs ("whole-row Var")
237
+ */
238
+ AttrNumber varattno;
239
+
240
+ /* pg_type OID for the type of this var */
241
+ Oid vartype pg_node_attr(query_jumble_ignore);
242
+ /* pg_attribute typmod value */
243
+ int32 vartypmod pg_node_attr(query_jumble_ignore);
244
+ /* OID of collation, or InvalidOid if none */
245
+ Oid varcollid pg_node_attr(query_jumble_ignore);
246
+
247
+ /*
248
+ * RT indexes of outer joins that can replace the Var's value with null.
249
+ * We can omit varnullingrels in the query jumble, because it's fully
250
+ * determined by varno/varlevelsup plus the Var's query location.
251
+ */
252
+ Bitmapset *varnullingrels pg_node_attr(query_jumble_ignore);
253
+
254
+ /*
255
+ * for subquery variables referencing outer relations; 0 in a normal var,
256
+ * >0 means N levels up
257
+ */
258
+ Index varlevelsup;
259
+
260
+ /*
261
+ * varnosyn/varattnosyn are ignored for equality, because Vars with
262
+ * different syntactic identifiers are semantically the same as long as
263
+ * their varno/varattno match.
264
+ */
265
+ /* syntactic relation index (0 if unknown) */
266
+ Index varnosyn pg_node_attr(equal_ignore, query_jumble_ignore);
267
+ /* syntactic attribute number */
268
+ AttrNumber varattnosyn pg_node_attr(equal_ignore, query_jumble_ignore);
269
+
270
+ /* token location, or -1 if unknown */
271
+ int location;
202
272
  } Var;
203
273
 
204
274
  /*
@@ -208,22 +278,39 @@ typedef struct Var
208
278
  * must be in non-extended form (4-byte header, no compression or external
209
279
  * references). This ensures that the Const node is self-contained and makes
210
280
  * it more likely that equal() will see logically identical values as equal.
281
+ *
282
+ * Only the constant type OID is relevant for the query jumbling.
211
283
  */
212
284
  typedef struct Const
213
285
  {
286
+ pg_node_attr(custom_copy_equal, custom_read_write)
287
+
214
288
  Expr xpr;
215
- Oid consttype; /* pg_type OID of the constant's datatype */
216
- int32 consttypmod; /* typmod value, if any */
217
- Oid constcollid; /* OID of collation, or InvalidOid if none */
218
- int constlen; /* typlen of the constant's datatype */
219
- Datum constvalue; /* the constant's value */
220
- bool constisnull; /* whether the constant is null (if true,
221
- * constvalue is undefined) */
222
- bool constbyval; /* whether this datatype is passed by value.
223
- * If true, then all the information is stored
224
- * in the Datum. If false, then the Datum
225
- * contains a pointer to the information. */
226
- int location; /* token location, or -1 if unknown */
289
+ /* pg_type OID of the constant's datatype */
290
+ Oid consttype;
291
+ /* typmod value, if any */
292
+ int32 consttypmod pg_node_attr(query_jumble_ignore);
293
+ /* OID of collation, or InvalidOid if none */
294
+ Oid constcollid pg_node_attr(query_jumble_ignore);
295
+ /* typlen of the constant's datatype */
296
+ int constlen pg_node_attr(query_jumble_ignore);
297
+ /* the constant's value */
298
+ Datum constvalue pg_node_attr(query_jumble_ignore);
299
+ /* whether the constant is null (if true, constvalue is undefined) */
300
+ bool constisnull pg_node_attr(query_jumble_ignore);
301
+
302
+ /*
303
+ * Whether this datatype is passed by value. If true, then all the
304
+ * information is stored in the Datum. If false, then the Datum contains
305
+ * a pointer to the information.
306
+ */
307
+ bool constbyval pg_node_attr(query_jumble_ignore);
308
+
309
+ /*
310
+ * token location, or -1 if unknown. All constants are tracked as
311
+ * locations in query jumbling, to be marked as parameters.
312
+ */
313
+ int location pg_node_attr(query_jumble_location);
227
314
  } Const;
228
315
 
229
316
  /*
@@ -267,9 +354,12 @@ typedef struct Param
267
354
  ParamKind paramkind; /* kind of parameter. See above */
268
355
  int paramid; /* numeric ID for parameter */
269
356
  Oid paramtype; /* pg_type OID of parameter's datatype */
270
- int32 paramtypmod; /* typmod value, if known */
271
- Oid paramcollid; /* OID of collation, or InvalidOid if none */
272
- int location; /* token location, or -1 if unknown */
357
+ /* typmod value, if known */
358
+ int32 paramtypmod pg_node_attr(query_jumble_ignore);
359
+ /* OID of collation, or InvalidOid if none */
360
+ Oid paramcollid pg_node_attr(query_jumble_ignore);
361
+ /* token location, or -1 if unknown */
362
+ int location;
273
363
  } Param;
274
364
 
275
365
  /*
@@ -304,6 +394,10 @@ typedef struct Param
304
394
  * replaced with a single argument representing the partial-aggregate
305
395
  * transition values.
306
396
  *
397
+ * aggpresorted is set by the query planner for ORDER BY and DISTINCT
398
+ * aggregates where the chosen plan provides presorted input for this
399
+ * aggregate during execution.
400
+ *
307
401
  * aggsplit indicates the expected partial-aggregation mode for the Aggref's
308
402
  * parent plan node. It's always set to AGGSPLIT_SIMPLE in the parser, but
309
403
  * the planner might change it to something else. We use this mainly as
@@ -316,30 +410,79 @@ typedef struct Param
316
410
  * and can share the result. Aggregates with same 'transno' but different
317
411
  * 'aggno' can share the same transition state, only the final function needs
318
412
  * to be called separately.
413
+ *
414
+ * Information related to collations, transition types and internal states
415
+ * are irrelevant for the query jumbling.
319
416
  */
320
417
  typedef struct Aggref
321
418
  {
322
419
  Expr xpr;
323
- Oid aggfnoid; /* pg_proc Oid of the aggregate */
324
- Oid aggtype; /* type Oid of result of the aggregate */
325
- Oid aggcollid; /* OID of collation of result */
326
- Oid inputcollid; /* OID of collation that function should use */
327
- Oid aggtranstype; /* type Oid of aggregate's transition value */
328
- List *aggargtypes; /* type Oids of direct and aggregated args */
329
- List *aggdirectargs; /* direct arguments, if an ordered-set agg */
330
- List *args; /* aggregated arguments and sort expressions */
331
- List *aggorder; /* ORDER BY (list of SortGroupClause) */
332
- List *aggdistinct; /* DISTINCT (list of SortGroupClause) */
333
- Expr *aggfilter; /* FILTER expression, if any */
334
- bool aggstar; /* true if argument list was really '*' */
335
- bool aggvariadic; /* true if variadic arguments have been
336
- * combined into an array last argument */
337
- char aggkind; /* aggregate kind (see pg_aggregate.h) */
338
- Index agglevelsup; /* > 0 if agg belongs to outer query */
339
- AggSplit aggsplit; /* expected agg-splitting mode of parent Agg */
340
- int aggno; /* unique ID within the Agg node */
341
- int aggtransno; /* unique ID of transition state in the Agg */
342
- int location; /* token location, or -1 if unknown */
420
+
421
+ /* pg_proc Oid of the aggregate */
422
+ Oid aggfnoid;
423
+
424
+ /* type Oid of result of the aggregate */
425
+ Oid aggtype pg_node_attr(query_jumble_ignore);
426
+
427
+ /* OID of collation of result */
428
+ Oid aggcollid pg_node_attr(query_jumble_ignore);
429
+
430
+ /* OID of collation that function should use */
431
+ Oid inputcollid pg_node_attr(query_jumble_ignore);
432
+
433
+ /*
434
+ * type Oid of aggregate's transition value; ignored for equal since it
435
+ * might not be set yet
436
+ */
437
+ Oid aggtranstype pg_node_attr(equal_ignore, query_jumble_ignore);
438
+
439
+ /* type Oids of direct and aggregated args */
440
+ List *aggargtypes pg_node_attr(query_jumble_ignore);
441
+
442
+ /* direct arguments, if an ordered-set agg */
443
+ List *aggdirectargs;
444
+
445
+ /* aggregated arguments and sort expressions */
446
+ List *args;
447
+
448
+ /* ORDER BY (list of SortGroupClause) */
449
+ List *aggorder;
450
+
451
+ /* DISTINCT (list of SortGroupClause) */
452
+ List *aggdistinct;
453
+
454
+ /* FILTER expression, if any */
455
+ Expr *aggfilter;
456
+
457
+ /* true if argument list was really '*' */
458
+ bool aggstar pg_node_attr(query_jumble_ignore);
459
+
460
+ /*
461
+ * true if variadic arguments have been combined into an array last
462
+ * argument
463
+ */
464
+ bool aggvariadic pg_node_attr(query_jumble_ignore);
465
+
466
+ /* aggregate kind (see pg_aggregate.h) */
467
+ char aggkind pg_node_attr(query_jumble_ignore);
468
+
469
+ /* aggregate input already sorted */
470
+ bool aggpresorted pg_node_attr(equal_ignore, query_jumble_ignore);
471
+
472
+ /* > 0 if agg belongs to outer query */
473
+ Index agglevelsup pg_node_attr(query_jumble_ignore);
474
+
475
+ /* expected agg-splitting mode of parent Agg */
476
+ AggSplit aggsplit pg_node_attr(query_jumble_ignore);
477
+
478
+ /* unique ID within the Agg node */
479
+ int aggno pg_node_attr(query_jumble_ignore);
480
+
481
+ /* unique ID of transition state in the Agg */
482
+ int aggtransno pg_node_attr(query_jumble_ignore);
483
+
484
+ /* token location, or -1 if unknown */
485
+ int location;
343
486
  } Aggref;
344
487
 
345
488
  /*
@@ -365,34 +508,59 @@ typedef struct Aggref
365
508
  *
366
509
  * In raw parse output we have only the args list; parse analysis fills in the
367
510
  * refs list, and the planner fills in the cols list.
511
+ *
512
+ * All the fields used as information for an internal state are irrelevant
513
+ * for the query jumbling.
368
514
  */
369
515
  typedef struct GroupingFunc
370
516
  {
371
517
  Expr xpr;
372
- List *args; /* arguments, not evaluated but kept for
373
- * benefit of EXPLAIN etc. */
374
- List *refs; /* ressortgrouprefs of arguments */
375
- List *cols; /* actual column positions set by planner */
376
- Index agglevelsup; /* same as Aggref.agglevelsup */
377
- int location; /* token location */
518
+
519
+ /* arguments, not evaluated but kept for benefit of EXPLAIN etc. */
520
+ List *args pg_node_attr(query_jumble_ignore);
521
+
522
+ /* ressortgrouprefs of arguments */
523
+ List *refs pg_node_attr(equal_ignore);
524
+
525
+ /* actual column positions set by planner */
526
+ List *cols pg_node_attr(equal_ignore, query_jumble_ignore);
527
+
528
+ /* same as Aggref.agglevelsup */
529
+ Index agglevelsup;
530
+
531
+ /* token location */
532
+ int location;
378
533
  } GroupingFunc;
379
534
 
380
535
  /*
381
536
  * WindowFunc
537
+ *
538
+ * Collation information is irrelevant for the query jumbling, as is the
539
+ * internal state information of the node like "winstar" and "winagg".
382
540
  */
383
541
  typedef struct WindowFunc
384
542
  {
385
543
  Expr xpr;
386
- Oid winfnoid; /* pg_proc Oid of the function */
387
- Oid wintype; /* type Oid of result of the window function */
388
- Oid wincollid; /* OID of collation of result */
389
- Oid inputcollid; /* OID of collation that function should use */
390
- List *args; /* arguments to the window function */
391
- Expr *aggfilter; /* FILTER expression, if any */
392
- Index winref; /* index of associated WindowClause */
393
- bool winstar; /* true if argument list was really '*' */
394
- bool winagg; /* is function a simple aggregate? */
395
- int location; /* token location, or -1 if unknown */
544
+ /* pg_proc Oid of the function */
545
+ Oid winfnoid;
546
+ /* type Oid of result of the window function */
547
+ Oid wintype pg_node_attr(query_jumble_ignore);
548
+ /* OID of collation of result */
549
+ Oid wincollid pg_node_attr(query_jumble_ignore);
550
+ /* OID of collation that function should use */
551
+ Oid inputcollid pg_node_attr(query_jumble_ignore);
552
+ /* arguments to the window function */
553
+ List *args;
554
+ /* FILTER expression, if any */
555
+ Expr *aggfilter;
556
+ /* index of associated WindowClause */
557
+ Index winref;
558
+ /* true if argument list was really '*' */
559
+ bool winstar pg_node_attr(query_jumble_ignore);
560
+ /* is function a simple aggregate? */
561
+ bool winagg pg_node_attr(query_jumble_ignore);
562
+ /* token location, or -1 if unknown */
563
+ int location;
396
564
  } WindowFunc;
397
565
 
398
566
  /*
@@ -429,6 +597,8 @@ typedef struct WindowFunc
429
597
  * subscripting logic. Likewise, reftypmod and refcollid will match the
430
598
  * container's properties in a store, but could be different in a fetch.
431
599
  *
600
+ * Any internal state data is ignored for the query jumbling.
601
+ *
432
602
  * Note: for the cases where a container is returned, if refexpr yields a R/W
433
603
  * expanded container, then the implementation is allowed to modify that
434
604
  * object in-place and return the same object.
@@ -436,20 +606,28 @@ typedef struct WindowFunc
436
606
  typedef struct SubscriptingRef
437
607
  {
438
608
  Expr xpr;
439
- Oid refcontainertype; /* type of the container proper */
440
- Oid refelemtype; /* the container type's pg_type.typelem */
441
- Oid refrestype; /* type of the SubscriptingRef's result */
442
- int32 reftypmod; /* typmod of the result */
443
- Oid refcollid; /* collation of result, or InvalidOid if none */
444
- List *refupperindexpr; /* expressions that evaluate to upper
445
- * container indexes */
446
- List *reflowerindexpr; /* expressions that evaluate to lower
447
- * container indexes, or NIL for single
448
- * container element */
449
- Expr *refexpr; /* the expression that evaluates to a
450
- * container value */
451
- Expr *refassgnexpr; /* expression for the source value, or NULL if
452
- * fetch */
609
+ /* type of the container proper */
610
+ Oid refcontainertype pg_node_attr(query_jumble_ignore);
611
+ /* the container type's pg_type.typelem */
612
+ Oid refelemtype pg_node_attr(query_jumble_ignore);
613
+ /* type of the SubscriptingRef's result */
614
+ Oid refrestype pg_node_attr(query_jumble_ignore);
615
+ /* typmod of the result */
616
+ int32 reftypmod pg_node_attr(query_jumble_ignore);
617
+ /* collation of result, or InvalidOid if none */
618
+ Oid refcollid pg_node_attr(query_jumble_ignore);
619
+ /* expressions that evaluate to upper container indexes */
620
+ List *refupperindexpr;
621
+
622
+ /*
623
+ * expressions that evaluate to lower container indexes, or NIL for single
624
+ * container element.
625
+ */
626
+ List *reflowerindexpr;
627
+ /* the expression that evaluates to a container value */
628
+ Expr *refexpr;
629
+ /* expression for the source value, or NULL if fetch */
630
+ Expr *refassgnexpr;
453
631
  } SubscriptingRef;
454
632
 
455
633
  /*
@@ -488,20 +666,35 @@ typedef enum CoercionForm
488
666
 
489
667
  /*
490
668
  * FuncExpr - expression node for a function call
669
+ *
670
+ * Collation information is irrelevant for the query jumbling, only the
671
+ * arguments and the function OID matter.
491
672
  */
492
673
  typedef struct FuncExpr
493
674
  {
494
675
  Expr xpr;
495
- Oid funcid; /* PG_PROC OID of the function */
496
- Oid funcresulttype; /* PG_TYPE OID of result value */
497
- bool funcretset; /* true if function returns set */
498
- bool funcvariadic; /* true if variadic arguments have been
499
- * combined into an array last argument */
500
- CoercionForm funcformat; /* how to display this function call */
501
- Oid funccollid; /* OID of collation of result */
502
- Oid inputcollid; /* OID of collation that function should use */
503
- List *args; /* arguments to the function */
504
- int location; /* token location, or -1 if unknown */
676
+ /* PG_PROC OID of the function */
677
+ Oid funcid;
678
+ /* PG_TYPE OID of result value */
679
+ Oid funcresulttype pg_node_attr(query_jumble_ignore);
680
+ /* true if function returns set */
681
+ bool funcretset pg_node_attr(query_jumble_ignore);
682
+
683
+ /*
684
+ * true if variadic arguments have been combined into an array last
685
+ * argument
686
+ */
687
+ bool funcvariadic pg_node_attr(query_jumble_ignore);
688
+ /* how to display this function call */
689
+ CoercionForm funcformat pg_node_attr(query_jumble_ignore);
690
+ /* OID of collation of result */
691
+ Oid funccollid pg_node_attr(query_jumble_ignore);
692
+ /* OID of collation that function should use */
693
+ Oid inputcollid pg_node_attr(query_jumble_ignore);
694
+ /* arguments to the function */
695
+ List *args;
696
+ /* token location, or -1 if unknown */
697
+ int location;
505
698
  } FuncExpr;
506
699
 
507
700
  /*
@@ -521,10 +714,14 @@ typedef struct FuncExpr
521
714
  typedef struct NamedArgExpr
522
715
  {
523
716
  Expr xpr;
524
- Expr *arg; /* the argument expression */
525
- char *name; /* the name */
526
- int argnumber; /* argument's number in positional notation */
527
- int location; /* argument name location, or -1 if unknown */
717
+ /* the argument expression */
718
+ Expr *arg;
719
+ /* the name */
720
+ char *name pg_node_attr(query_jumble_ignore);
721
+ /* argument's number in positional notation */
722
+ int argnumber;
723
+ /* argument name location, or -1 if unknown */
724
+ int location;
528
725
  } NamedArgExpr;
529
726
 
530
727
  /*
@@ -535,18 +732,38 @@ typedef struct NamedArgExpr
535
732
  * Note that opfuncid is not necessarily filled in immediately on creation
536
733
  * of the node. The planner makes sure it is valid before passing the node
537
734
  * tree to the executor, but during parsing/planning opfuncid can be 0.
735
+ * Therefore, equal() will accept a zero value as being equal to other values.
736
+ *
737
+ * Internal state information and collation data is irrelevant for the query
738
+ * jumbling.
538
739
  */
539
740
  typedef struct OpExpr
540
741
  {
541
742
  Expr xpr;
542
- Oid opno; /* PG_OPERATOR OID of the operator */
543
- Oid opfuncid; /* PG_PROC OID of underlying function */
544
- Oid opresulttype; /* PG_TYPE OID of result value */
545
- bool opretset; /* true if operator returns set */
546
- Oid opcollid; /* OID of collation of result */
547
- Oid inputcollid; /* OID of collation that operator should use */
548
- List *args; /* arguments to the operator (1 or 2) */
549
- int location; /* token location, or -1 if unknown */
743
+
744
+ /* PG_OPERATOR OID of the operator */
745
+ Oid opno;
746
+
747
+ /* PG_PROC OID of underlying function */
748
+ Oid opfuncid pg_node_attr(equal_ignore_if_zero, query_jumble_ignore);
749
+
750
+ /* PG_TYPE OID of result value */
751
+ Oid opresulttype pg_node_attr(query_jumble_ignore);
752
+
753
+ /* true if operator returns set */
754
+ bool opretset pg_node_attr(query_jumble_ignore);
755
+
756
+ /* OID of collation of result */
757
+ Oid opcollid pg_node_attr(query_jumble_ignore);
758
+
759
+ /* OID of collation that operator should use */
760
+ Oid inputcollid pg_node_attr(query_jumble_ignore);
761
+
762
+ /* arguments to the operator (1 or 2) */
763
+ List *args;
764
+
765
+ /* token location, or -1 if unknown */
766
+ int location;
550
767
  } OpExpr;
551
768
 
552
769
  /*
@@ -592,19 +809,41 @@ typedef OpExpr NullIfExpr;
592
809
  * corresponding function and won't be used during execution. For
593
810
  * non-hashtable based NOT INs, negfuncid will be set to InvalidOid. See
594
811
  * convert_saop_to_hashed_saop().
812
+ *
813
+ * Similar to OpExpr, opfuncid, hashfuncid, and negfuncid are not necessarily
814
+ * filled in right away, so will be ignored for equality if they are not set
815
+ * yet.
816
+ *
817
+ * OID entries of the internal function types are irrelevant for the query
818
+ * jumbling, but the operator OID and the arguments are.
595
819
  */
596
820
  typedef struct ScalarArrayOpExpr
597
821
  {
598
822
  Expr xpr;
599
- Oid opno; /* PG_OPERATOR OID of the operator */
600
- Oid opfuncid; /* PG_PROC OID of comparison function */
601
- Oid hashfuncid; /* PG_PROC OID of hash func or InvalidOid */
602
- Oid negfuncid; /* PG_PROC OID of negator of opfuncid function
603
- * or InvalidOid. See above */
604
- bool useOr; /* true for ANY, false for ALL */
605
- Oid inputcollid; /* OID of collation that operator should use */
606
- List *args; /* the scalar and array operands */
607
- int location; /* token location, or -1 if unknown */
823
+
824
+ /* PG_OPERATOR OID of the operator */
825
+ Oid opno;
826
+
827
+ /* PG_PROC OID of comparison function */
828
+ Oid opfuncid pg_node_attr(equal_ignore_if_zero, query_jumble_ignore);
829
+
830
+ /* PG_PROC OID of hash func or InvalidOid */
831
+ Oid hashfuncid pg_node_attr(equal_ignore_if_zero, query_jumble_ignore);
832
+
833
+ /* PG_PROC OID of negator of opfuncid function or InvalidOid. See above */
834
+ Oid negfuncid pg_node_attr(equal_ignore_if_zero, query_jumble_ignore);
835
+
836
+ /* true for ANY, false for ALL */
837
+ bool useOr;
838
+
839
+ /* OID of collation that operator should use */
840
+ Oid inputcollid pg_node_attr(query_jumble_ignore);
841
+
842
+ /* the scalar and array operands */
843
+ List *args;
844
+
845
+ /* token location, or -1 if unknown */
846
+ int location;
608
847
  } ScalarArrayOpExpr;
609
848
 
610
849
  /*
@@ -621,6 +860,8 @@ typedef enum BoolExprType
621
860
 
622
861
  typedef struct BoolExpr
623
862
  {
863
+ pg_node_attr(custom_read_write)
864
+
624
865
  Expr xpr;
625
866
  BoolExprType boolop;
626
867
  List *args; /* arguments to this expression */
@@ -697,8 +938,10 @@ typedef struct SubLink
697
938
  SubLinkType subLinkType; /* see above */
698
939
  int subLinkId; /* ID (1..n); 0 if not MULTIEXPR */
699
940
  Node *testexpr; /* outer-query test for ALL/ANY/ROWCOMPARE */
700
- List *operName; /* originally specified operator name */
701
- Node *subselect; /* subselect as Query* or raw parsetree */
941
+ /* originally specified operator name */
942
+ List *operName pg_node_attr(query_jumble_ignore);
943
+ /* subselect as Query* or raw parsetree */
944
+ Node *subselect;
702
945
  int location; /* token location, or -1 if unknown */
703
946
  } SubLink;
704
947
 
@@ -732,9 +975,9 @@ typedef struct SubLink
732
975
  * The values are assigned to the global PARAM_EXEC params indexed by parParam
733
976
  * (the parParam and args lists must have the same ordering). setParam is a
734
977
  * list of the PARAM_EXEC params that are computed by the sub-select, if it
735
- * is an initplan; they are listed in order by sub-select output column
736
- * position. (parParam and setParam are integer Lists, not Bitmapsets,
737
- * because their ordering is significant.)
978
+ * is an initplan or MULTIEXPR plan; they are listed in order by sub-select
979
+ * output column position. (parParam and setParam are integer Lists, not
980
+ * Bitmapsets, because their ordering is significant.)
738
981
  *
739
982
  * Also, the planner computes startup and per-call costs for use of the
740
983
  * SubPlan. Note that these include the cost of the subquery proper,
@@ -742,6 +985,8 @@ typedef struct SubLink
742
985
  */
743
986
  typedef struct SubPlan
744
987
  {
988
+ pg_node_attr(no_query_jumble)
989
+
745
990
  Expr xpr;
746
991
  /* Fields copied from original SubLink: */
747
992
  SubLinkType subLinkType; /* see above */
@@ -767,8 +1012,8 @@ typedef struct SubPlan
767
1012
  /* Note: parallel_safe does not consider contents of testexpr or args */
768
1013
  /* Information for passing params into and out of the subselect: */
769
1014
  /* setParam and parParam are lists of integers (param IDs) */
770
- List *setParam; /* initplan subqueries have to set these
771
- * Params for parent plan */
1015
+ List *setParam; /* initplan and MULTIEXPR subqueries have to
1016
+ * set these Params for parent plan */
772
1017
  List *parParam; /* indices of input Params from parent plan */
773
1018
  List *args; /* exprs to pass as parParam values */
774
1019
  /* Estimated execution costs: */
@@ -789,6 +1034,8 @@ typedef struct SubPlan
789
1034
  */
790
1035
  typedef struct AlternativeSubPlan
791
1036
  {
1037
+ pg_node_attr(no_query_jumble)
1038
+
792
1039
  Expr xpr;
793
1040
  List *subplans; /* SubPlan(s) with equivalent results */
794
1041
  } AlternativeSubPlan;
@@ -807,10 +1054,12 @@ typedef struct FieldSelect
807
1054
  Expr xpr;
808
1055
  Expr *arg; /* input expression */
809
1056
  AttrNumber fieldnum; /* attribute number of field to extract */
810
- Oid resulttype; /* type of the field (result type of this
811
- * node) */
812
- int32 resulttypmod; /* output typmod (usually -1) */
813
- Oid resultcollid; /* OID of collation of the field */
1057
+ /* type of the field (result type of this node) */
1058
+ Oid resulttype pg_node_attr(query_jumble_ignore);
1059
+ /* output typmod (usually -1) */
1060
+ int32 resulttypmod pg_node_attr(query_jumble_ignore);
1061
+ /* OID of collation of the field */
1062
+ Oid resultcollid pg_node_attr(query_jumble_ignore);
814
1063
  } FieldSelect;
815
1064
 
816
1065
  /* ----------------
@@ -836,8 +1085,10 @@ typedef struct FieldStore
836
1085
  Expr xpr;
837
1086
  Expr *arg; /* input tuple value */
838
1087
  List *newvals; /* new value(s) for field(s) */
839
- List *fieldnums; /* integer list of field attnums */
840
- Oid resulttype; /* type of result (same as type of arg) */
1088
+ /* integer list of field attnums */
1089
+ List *fieldnums pg_node_attr(query_jumble_ignore);
1090
+ /* type of result (same as type of arg) */
1091
+ Oid resulttype pg_node_attr(query_jumble_ignore);
841
1092
  /* Like RowExpr, we deliberately omit a typmod and collation here */
842
1093
  } FieldStore;
843
1094
 
@@ -859,9 +1110,12 @@ typedef struct RelabelType
859
1110
  Expr xpr;
860
1111
  Expr *arg; /* input expression */
861
1112
  Oid resulttype; /* output type of coercion expression */
862
- int32 resulttypmod; /* output typmod (usually -1) */
863
- Oid resultcollid; /* OID of collation, or InvalidOid if none */
864
- CoercionForm relabelformat; /* how to display this node */
1113
+ /* output typmod (usually -1) */
1114
+ int32 resulttypmod pg_node_attr(query_jumble_ignore);
1115
+ /* OID of collation, or InvalidOid if none */
1116
+ Oid resultcollid pg_node_attr(query_jumble_ignore);
1117
+ /* how to display this node */
1118
+ CoercionForm relabelformat pg_node_attr(query_jumble_ignore);
865
1119
  int location; /* token location, or -1 if unknown */
866
1120
  } RelabelType;
867
1121
 
@@ -880,8 +1134,10 @@ typedef struct CoerceViaIO
880
1134
  Expr *arg; /* input expression */
881
1135
  Oid resulttype; /* output type of coercion */
882
1136
  /* output typmod is not stored, but is presumed -1 */
883
- Oid resultcollid; /* OID of collation, or InvalidOid if none */
884
- CoercionForm coerceformat; /* how to display this node */
1137
+ /* OID of collation, or InvalidOid if none */
1138
+ Oid resultcollid pg_node_attr(query_jumble_ignore);
1139
+ /* how to display this node */
1140
+ CoercionForm coerceformat pg_node_attr(query_jumble_ignore);
885
1141
  int location; /* token location, or -1 if unknown */
886
1142
  } CoerceViaIO;
887
1143
 
@@ -904,9 +1160,12 @@ typedef struct ArrayCoerceExpr
904
1160
  Expr *arg; /* input expression (yields an array) */
905
1161
  Expr *elemexpr; /* expression representing per-element work */
906
1162
  Oid resulttype; /* output type of coercion (an array type) */
907
- int32 resulttypmod; /* output typmod (also element typmod) */
908
- Oid resultcollid; /* OID of collation, or InvalidOid if none */
909
- CoercionForm coerceformat; /* how to display this node */
1163
+ /* output typmod (also element typmod) */
1164
+ int32 resulttypmod pg_node_attr(query_jumble_ignore);
1165
+ /* OID of collation, or InvalidOid if none */
1166
+ Oid resultcollid pg_node_attr(query_jumble_ignore);
1167
+ /* how to display this node */
1168
+ CoercionForm coerceformat pg_node_attr(query_jumble_ignore);
910
1169
  int location; /* token location, or -1 if unknown */
911
1170
  } ArrayCoerceExpr;
912
1171
 
@@ -929,7 +1188,8 @@ typedef struct ConvertRowtypeExpr
929
1188
  Expr *arg; /* input expression */
930
1189
  Oid resulttype; /* output type (always a composite type) */
931
1190
  /* Like RowExpr, we deliberately omit a typmod and collation here */
932
- CoercionForm convertformat; /* how to display this node */
1191
+ /* how to display this node */
1192
+ CoercionForm convertformat pg_node_attr(query_jumble_ignore);
933
1193
  int location; /* token location, or -1 if unknown */
934
1194
  } ConvertRowtypeExpr;
935
1195
 
@@ -973,8 +1233,10 @@ typedef struct CollateExpr
973
1233
  typedef struct CaseExpr
974
1234
  {
975
1235
  Expr xpr;
976
- Oid casetype; /* type of expression result */
977
- Oid casecollid; /* OID of collation, or InvalidOid if none */
1236
+ /* type of expression result */
1237
+ Oid casetype pg_node_attr(query_jumble_ignore);
1238
+ /* OID of collation, or InvalidOid if none */
1239
+ Oid casecollid pg_node_attr(query_jumble_ignore);
978
1240
  Expr *arg; /* implicit equality comparison argument */
979
1241
  List *args; /* the arguments (list of WHEN clauses) */
980
1242
  Expr *defresult; /* the default result (ELSE clause) */
@@ -1002,6 +1264,8 @@ typedef struct CaseWhen
1002
1264
  * see build_coercion_expression().
1003
1265
  * * Nested FieldStore/SubscriptingRef assignment expressions in INSERT/UPDATE;
1004
1266
  * see transformAssignmentIndirection().
1267
+ * * Placeholder for intermediate results in some SQL/JSON expression nodes,
1268
+ * such as JsonConstructorExpr.
1005
1269
  *
1006
1270
  * The uses in CaseExpr and ArrayCoerceExpr are safe only to the extent that
1007
1271
  * there is not any other CaseExpr or ArrayCoerceExpr between the value source
@@ -1016,8 +1280,10 @@ typedef struct CaseTestExpr
1016
1280
  {
1017
1281
  Expr xpr;
1018
1282
  Oid typeId; /* type for substituted value */
1019
- int32 typeMod; /* typemod for substituted value */
1020
- Oid collation; /* collation for the substituted value */
1283
+ /* typemod for substituted value */
1284
+ int32 typeMod pg_node_attr(query_jumble_ignore);
1285
+ /* collation for the substituted value */
1286
+ Oid collation pg_node_attr(query_jumble_ignore);
1021
1287
  } CaseTestExpr;
1022
1288
 
1023
1289
  /*
@@ -1031,12 +1297,18 @@ typedef struct CaseTestExpr
1031
1297
  typedef struct ArrayExpr
1032
1298
  {
1033
1299
  Expr xpr;
1034
- Oid array_typeid; /* type of expression result */
1035
- Oid array_collid; /* OID of collation, or InvalidOid if none */
1036
- Oid element_typeid; /* common type of array elements */
1037
- List *elements; /* the array elements or sub-arrays */
1038
- bool multidims; /* true if elements are sub-arrays */
1039
- int location; /* token location, or -1 if unknown */
1300
+ /* type of expression result */
1301
+ Oid array_typeid pg_node_attr(query_jumble_ignore);
1302
+ /* OID of collation, or InvalidOid if none */
1303
+ Oid array_collid pg_node_attr(query_jumble_ignore);
1304
+ /* common type of array elements */
1305
+ Oid element_typeid pg_node_attr(query_jumble_ignore);
1306
+ /* the array elements or sub-arrays */
1307
+ List *elements;
1308
+ /* true if elements are sub-arrays */
1309
+ bool multidims pg_node_attr(query_jumble_ignore);
1310
+ /* token location, or -1 if unknown */
1311
+ int location;
1040
1312
  } ArrayExpr;
1041
1313
 
1042
1314
  /*
@@ -1064,7 +1336,9 @@ typedef struct RowExpr
1064
1336
  {
1065
1337
  Expr xpr;
1066
1338
  List *args; /* the fields */
1067
- Oid row_typeid; /* RECORDOID or a composite type's ID */
1339
+
1340
+ /* RECORDOID or a composite type's ID */
1341
+ Oid row_typeid pg_node_attr(query_jumble_ignore);
1068
1342
 
1069
1343
  /*
1070
1344
  * row_typeid cannot be a domain over composite, only plain composite. To
@@ -1078,8 +1352,13 @@ typedef struct RowExpr
1078
1352
  * We don't need to store a collation either. The result type is
1079
1353
  * necessarily composite, and composite types never have a collation.
1080
1354
  */
1081
- CoercionForm row_format; /* how to display this node */
1082
- List *colnames; /* list of String, or NIL */
1355
+
1356
+ /* how to display this node */
1357
+ CoercionForm row_format pg_node_attr(query_jumble_ignore);
1358
+
1359
+ /* list of String, or NIL */
1360
+ List *colnames pg_node_attr(query_jumble_ignore);
1361
+
1083
1362
  int location; /* token location, or -1 if unknown */
1084
1363
  } RowExpr;
1085
1364
 
@@ -1111,12 +1390,19 @@ typedef enum RowCompareType
1111
1390
  typedef struct RowCompareExpr
1112
1391
  {
1113
1392
  Expr xpr;
1114
- RowCompareType rctype; /* LT LE GE or GT, never EQ or NE */
1115
- List *opnos; /* OID list of pairwise comparison ops */
1116
- List *opfamilies; /* OID list of containing operator families */
1117
- List *inputcollids; /* OID list of collations for comparisons */
1118
- List *largs; /* the left-hand input arguments */
1119
- List *rargs; /* the right-hand input arguments */
1393
+
1394
+ /* LT LE GE or GT, never EQ or NE */
1395
+ RowCompareType rctype;
1396
+ /* OID list of pairwise comparison ops */
1397
+ List *opnos pg_node_attr(query_jumble_ignore);
1398
+ /* OID list of containing operator families */
1399
+ List *opfamilies pg_node_attr(query_jumble_ignore);
1400
+ /* OID list of collations for comparisons */
1401
+ List *inputcollids pg_node_attr(query_jumble_ignore);
1402
+ /* the left-hand input arguments */
1403
+ List *largs;
1404
+ /* the right-hand input arguments */
1405
+ List *rargs;
1120
1406
  } RowCompareExpr;
1121
1407
 
1122
1408
  /*
@@ -1125,10 +1411,14 @@ typedef struct RowCompareExpr
1125
1411
  typedef struct CoalesceExpr
1126
1412
  {
1127
1413
  Expr xpr;
1128
- Oid coalescetype; /* type of expression result */
1129
- Oid coalescecollid; /* OID of collation, or InvalidOid if none */
1130
- List *args; /* the arguments */
1131
- int location; /* token location, or -1 if unknown */
1414
+ /* type of expression result */
1415
+ Oid coalescetype pg_node_attr(query_jumble_ignore);
1416
+ /* OID of collation, or InvalidOid if none */
1417
+ Oid coalescecollid pg_node_attr(query_jumble_ignore);
1418
+ /* the arguments */
1419
+ List *args;
1420
+ /* token location, or -1 if unknown */
1421
+ int location;
1132
1422
  } CoalesceExpr;
1133
1423
 
1134
1424
  /*
@@ -1143,12 +1433,18 @@ typedef enum MinMaxOp
1143
1433
  typedef struct MinMaxExpr
1144
1434
  {
1145
1435
  Expr xpr;
1146
- Oid minmaxtype; /* common type of arguments and result */
1147
- Oid minmaxcollid; /* OID of collation of result */
1148
- Oid inputcollid; /* OID of collation that function should use */
1149
- MinMaxOp op; /* function to execute */
1150
- List *args; /* the arguments */
1151
- int location; /* token location, or -1 if unknown */
1436
+ /* common type of arguments and result */
1437
+ Oid minmaxtype pg_node_attr(query_jumble_ignore);
1438
+ /* OID of collation of result */
1439
+ Oid minmaxcollid pg_node_attr(query_jumble_ignore);
1440
+ /* OID of collation that function should use */
1441
+ Oid inputcollid pg_node_attr(query_jumble_ignore);
1442
+ /* function to execute */
1443
+ MinMaxOp op;
1444
+ /* the arguments */
1445
+ List *args;
1446
+ /* token location, or -1 if unknown */
1447
+ int location;
1152
1448
  } MinMaxExpr;
1153
1449
 
1154
1450
  /*
@@ -1185,7 +1481,12 @@ typedef struct SQLValueFunction
1185
1481
  {
1186
1482
  Expr xpr;
1187
1483
  SQLValueFunctionOp op; /* which function this is */
1188
- Oid type; /* result type/typmod */
1484
+
1485
+ /*
1486
+ * Result type/typmod. Type is fully determined by "op", so no need to
1487
+ * include this Oid in the query jumbling.
1488
+ */
1489
+ Oid type pg_node_attr(query_jumble_ignore);
1189
1490
  int32 typmod;
1190
1491
  int location; /* token location, or -1 if unknown */
1191
1492
  } SQLValueFunction;
@@ -1209,7 +1510,7 @@ typedef enum XmlExprOp
1209
1510
  IS_XMLPARSE, /* XMLPARSE(text, is_doc, preserve_ws) */
1210
1511
  IS_XMLPI, /* XMLPI(name [, args]) */
1211
1512
  IS_XMLROOT, /* XMLROOT(xml, version, standalone) */
1212
- IS_XMLSERIALIZE, /* XMLSERIALIZE(is_document, xmlval) */
1513
+ IS_XMLSERIALIZE, /* XMLSERIALIZE(is_document, xmlval, indent) */
1213
1514
  IS_DOCUMENT /* xmlval IS DOCUMENT */
1214
1515
  } XmlExprOp;
1215
1516
 
@@ -1222,17 +1523,142 @@ typedef enum XmlOptionType
1222
1523
  typedef struct XmlExpr
1223
1524
  {
1224
1525
  Expr xpr;
1225
- XmlExprOp op; /* xml function ID */
1226
- char *name; /* name in xml(NAME foo ...) syntaxes */
1227
- List *named_args; /* non-XML expressions for xml_attributes */
1228
- List *arg_names; /* parallel list of String values */
1229
- List *args; /* list of expressions */
1230
- XmlOptionType xmloption; /* DOCUMENT or CONTENT */
1231
- Oid type; /* target type/typmod for XMLSERIALIZE */
1232
- int32 typmod;
1233
- int location; /* token location, or -1 if unknown */
1526
+ /* xml function ID */
1527
+ XmlExprOp op;
1528
+ /* name in xml(NAME foo ...) syntaxes */
1529
+ char *name pg_node_attr(query_jumble_ignore);
1530
+ /* non-XML expressions for xml_attributes */
1531
+ List *named_args;
1532
+ /* parallel list of String values */
1533
+ List *arg_names pg_node_attr(query_jumble_ignore);
1534
+ /* list of expressions */
1535
+ List *args;
1536
+ /* DOCUMENT or CONTENT */
1537
+ XmlOptionType xmloption pg_node_attr(query_jumble_ignore);
1538
+ /* INDENT option for XMLSERIALIZE */
1539
+ bool indent;
1540
+ /* target type/typmod for XMLSERIALIZE */
1541
+ Oid type pg_node_attr(query_jumble_ignore);
1542
+ int32 typmod pg_node_attr(query_jumble_ignore);
1543
+ /* token location, or -1 if unknown */
1544
+ int location;
1234
1545
  } XmlExpr;
1235
1546
 
1547
+ /*
1548
+ * JsonEncoding -
1549
+ * representation of JSON ENCODING clause
1550
+ */
1551
+ typedef enum JsonEncoding
1552
+ {
1553
+ JS_ENC_DEFAULT, /* unspecified */
1554
+ JS_ENC_UTF8,
1555
+ JS_ENC_UTF16,
1556
+ JS_ENC_UTF32,
1557
+ } JsonEncoding;
1558
+
1559
+ /*
1560
+ * JsonFormatType -
1561
+ * enumeration of JSON formats used in JSON FORMAT clause
1562
+ */
1563
+ typedef enum JsonFormatType
1564
+ {
1565
+ JS_FORMAT_DEFAULT, /* unspecified */
1566
+ JS_FORMAT_JSON, /* FORMAT JSON [ENCODING ...] */
1567
+ JS_FORMAT_JSONB /* implicit internal format for RETURNING
1568
+ * jsonb */
1569
+ } JsonFormatType;
1570
+
1571
+ /*
1572
+ * JsonFormat -
1573
+ * representation of JSON FORMAT clause
1574
+ */
1575
+ typedef struct JsonFormat
1576
+ {
1577
+ NodeTag type;
1578
+ JsonFormatType format_type; /* format type */
1579
+ JsonEncoding encoding; /* JSON encoding */
1580
+ int location; /* token location, or -1 if unknown */
1581
+ } JsonFormat;
1582
+
1583
+ /*
1584
+ * JsonReturning -
1585
+ * transformed representation of JSON RETURNING clause
1586
+ */
1587
+ typedef struct JsonReturning
1588
+ {
1589
+ NodeTag type;
1590
+ JsonFormat *format; /* output JSON format */
1591
+ Oid typid; /* target type Oid */
1592
+ int32 typmod; /* target type modifier */
1593
+ } JsonReturning;
1594
+
1595
+ /*
1596
+ * JsonValueExpr -
1597
+ * representation of JSON value expression (expr [FORMAT JsonFormat])
1598
+ *
1599
+ * The actual value is obtained by evaluating formatted_expr. raw_expr is
1600
+ * only there for displaying the original user-written expression and is not
1601
+ * evaluated by ExecInterpExpr() and eval_const_exprs_mutator().
1602
+ */
1603
+ typedef struct JsonValueExpr
1604
+ {
1605
+ NodeTag type;
1606
+ Expr *raw_expr; /* raw expression */
1607
+ Expr *formatted_expr; /* formatted expression */
1608
+ JsonFormat *format; /* FORMAT clause, if specified */
1609
+ } JsonValueExpr;
1610
+
1611
+ typedef enum JsonConstructorType
1612
+ {
1613
+ JSCTOR_JSON_OBJECT = 1,
1614
+ JSCTOR_JSON_ARRAY = 2,
1615
+ JSCTOR_JSON_OBJECTAGG = 3,
1616
+ JSCTOR_JSON_ARRAYAGG = 4
1617
+ } JsonConstructorType;
1618
+
1619
+ /*
1620
+ * JsonConstructorExpr -
1621
+ * wrapper over FuncExpr/Aggref/WindowFunc for SQL/JSON constructors
1622
+ */
1623
+ typedef struct JsonConstructorExpr
1624
+ {
1625
+ Expr xpr;
1626
+ JsonConstructorType type; /* constructor type */
1627
+ List *args;
1628
+ Expr *func; /* underlying json[b]_xxx() function call */
1629
+ Expr *coercion; /* coercion to RETURNING type */
1630
+ JsonReturning *returning; /* RETURNING clause */
1631
+ bool absent_on_null; /* ABSENT ON NULL? */
1632
+ bool unique; /* WITH UNIQUE KEYS? (JSON_OBJECT[AGG] only) */
1633
+ int location;
1634
+ } JsonConstructorExpr;
1635
+
1636
+ /*
1637
+ * JsonValueType -
1638
+ * representation of JSON item type in IS JSON predicate
1639
+ */
1640
+ typedef enum JsonValueType
1641
+ {
1642
+ JS_TYPE_ANY, /* IS JSON [VALUE] */
1643
+ JS_TYPE_OBJECT, /* IS JSON OBJECT */
1644
+ JS_TYPE_ARRAY, /* IS JSON ARRAY */
1645
+ JS_TYPE_SCALAR /* IS JSON SCALAR */
1646
+ } JsonValueType;
1647
+
1648
+ /*
1649
+ * JsonIsPredicate -
1650
+ * representation of IS JSON predicate
1651
+ */
1652
+ typedef struct JsonIsPredicate
1653
+ {
1654
+ NodeTag type;
1655
+ Node *expr; /* subject expression */
1656
+ JsonFormat *format; /* FORMAT clause, if specified */
1657
+ JsonValueType item_type; /* JSON item type */
1658
+ bool unique_keys; /* check key uniqueness? */
1659
+ int location; /* token location, or -1 if unknown */
1660
+ } JsonIsPredicate;
1661
+
1236
1662
  /* ----------------
1237
1663
  * NullTest
1238
1664
  *
@@ -1262,7 +1688,8 @@ typedef struct NullTest
1262
1688
  Expr xpr;
1263
1689
  Expr *arg; /* input expression */
1264
1690
  NullTestType nulltesttype; /* IS NULL, IS NOT NULL */
1265
- bool argisrow; /* T to perform field-by-field null checks */
1691
+ /* T to perform field-by-field null checks */
1692
+ bool argisrow pg_node_attr(query_jumble_ignore);
1266
1693
  int location; /* token location, or -1 if unknown */
1267
1694
  } NullTest;
1268
1695
 
@@ -1302,9 +1729,12 @@ typedef struct CoerceToDomain
1302
1729
  Expr xpr;
1303
1730
  Expr *arg; /* input expression */
1304
1731
  Oid resulttype; /* domain type ID (result type) */
1305
- int32 resulttypmod; /* output typmod (currently always -1) */
1306
- Oid resultcollid; /* OID of collation, or InvalidOid if none */
1307
- CoercionForm coercionformat; /* how to display this node */
1732
+ /* output typmod (currently always -1) */
1733
+ int32 resulttypmod pg_node_attr(query_jumble_ignore);
1734
+ /* OID of collation, or InvalidOid if none */
1735
+ Oid resultcollid pg_node_attr(query_jumble_ignore);
1736
+ /* how to display this node */
1737
+ CoercionForm coercionformat pg_node_attr(query_jumble_ignore);
1308
1738
  int location; /* token location, or -1 if unknown */
1309
1739
  } CoerceToDomain;
1310
1740
 
@@ -1320,10 +1750,14 @@ typedef struct CoerceToDomain
1320
1750
  typedef struct CoerceToDomainValue
1321
1751
  {
1322
1752
  Expr xpr;
1323
- Oid typeId; /* type for substituted value */
1324
- int32 typeMod; /* typemod for substituted value */
1325
- Oid collation; /* collation for the substituted value */
1326
- int location; /* token location, or -1 if unknown */
1753
+ /* type for substituted value */
1754
+ Oid typeId;
1755
+ /* typemod for substituted value */
1756
+ int32 typeMod pg_node_attr(query_jumble_ignore);
1757
+ /* collation for the substituted value */
1758
+ Oid collation pg_node_attr(query_jumble_ignore);
1759
+ /* token location, or -1 if unknown */
1760
+ int location;
1327
1761
  } CoerceToDomainValue;
1328
1762
 
1329
1763
  /*
@@ -1336,10 +1770,14 @@ typedef struct CoerceToDomainValue
1336
1770
  typedef struct SetToDefault
1337
1771
  {
1338
1772
  Expr xpr;
1339
- Oid typeId; /* type for substituted value */
1340
- int32 typeMod; /* typemod for substituted value */
1341
- Oid collation; /* collation for the substituted value */
1342
- int location; /* token location, or -1 if unknown */
1773
+ /* type for substituted value */
1774
+ Oid typeId;
1775
+ /* typemod for substituted value */
1776
+ int32 typeMod pg_node_attr(query_jumble_ignore);
1777
+ /* collation for the substituted value */
1778
+ Oid collation pg_node_attr(query_jumble_ignore);
1779
+ /* token location, or -1 if unknown */
1780
+ int location;
1343
1781
  } SetToDefault;
1344
1782
 
1345
1783
  /*
@@ -1450,15 +1888,20 @@ typedef struct InferenceElem
1450
1888
  typedef struct TargetEntry
1451
1889
  {
1452
1890
  Expr xpr;
1453
- Expr *expr; /* expression to evaluate */
1454
- AttrNumber resno; /* attribute number (see notes above) */
1455
- char *resname; /* name of the column (could be NULL) */
1456
- Index ressortgroupref; /* nonzero if referenced by a sort/group
1457
- * clause */
1458
- Oid resorigtbl; /* OID of column's source table */
1459
- AttrNumber resorigcol; /* column's number in source table */
1460
- bool resjunk; /* set to true to eliminate the attribute from
1461
- * final target list */
1891
+ /* expression to evaluate */
1892
+ Expr *expr;
1893
+ /* attribute number (see notes above) */
1894
+ AttrNumber resno;
1895
+ /* name of the column (could be NULL) */
1896
+ char *resname pg_node_attr(query_jumble_ignore);
1897
+ /* nonzero if referenced by a sort/group clause */
1898
+ Index ressortgroupref;
1899
+ /* OID of column's source table */
1900
+ Oid resorigtbl pg_node_attr(query_jumble_ignore);
1901
+ /* column's number in source table */
1902
+ AttrNumber resorigcol pg_node_attr(query_jumble_ignore);
1903
+ /* set to true to eliminate the attribute from final target list */
1904
+ bool resjunk pg_node_attr(query_jumble_ignore);
1462
1905
  } TargetEntry;
1463
1906
 
1464
1907
 
@@ -1540,11 +1983,16 @@ typedef struct JoinExpr
1540
1983
  bool isNatural; /* Natural join? Will need to shape table */
1541
1984
  Node *larg; /* left subtree */
1542
1985
  Node *rarg; /* right subtree */
1543
- List *usingClause; /* USING clause, if any (list of String) */
1544
- Alias *join_using_alias; /* alias attached to USING clause, if any */
1545
- Node *quals; /* qualifiers on join, if any */
1546
- Alias *alias; /* user-written alias clause, if any */
1547
- int rtindex; /* RT index assigned for join, or 0 */
1986
+ /* USING clause, if any (list of String) */
1987
+ List *usingClause pg_node_attr(query_jumble_ignore);
1988
+ /* alias attached to USING clause, if any */
1989
+ Alias *join_using_alias pg_node_attr(query_jumble_ignore);
1990
+ /* qualifiers on join, if any */
1991
+ Node *quals;
1992
+ /* user-written alias clause, if any */
1993
+ Alias *alias pg_node_attr(query_jumble_ignore);
1994
+ /* RT index assigned for join, or 0 */
1995
+ int rtindex;
1548
1996
  } JoinExpr;
1549
1997
 
1550
1998
  /*----------