pg_query 5.1.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (479) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/README.md +1 -1
  4. data/Rakefile +2 -2
  5. data/ext/pg_query/include/pg_query.h +4 -3
  6. data/ext/pg_query/include/pg_query_enum_defs.c +424 -154
  7. data/ext/pg_query/include/pg_query_fingerprint_conds.c +68 -4
  8. data/ext/pg_query/include/pg_query_fingerprint_defs.c +2952 -1845
  9. data/ext/pg_query/include/pg_query_outfuncs_conds.c +51 -3
  10. data/ext/pg_query/include/pg_query_outfuncs_defs.c +210 -23
  11. data/ext/pg_query/include/pg_query_readfuncs_conds.c +17 -1
  12. data/ext/pg_query/include/pg_query_readfuncs_defs.c +271 -52
  13. data/ext/pg_query/include/postgres/access/amapi.h +10 -3
  14. data/ext/pg_query/include/postgres/access/attmap.h +1 -1
  15. data/ext/pg_query/include/postgres/access/attnum.h +1 -1
  16. data/ext/pg_query/include/postgres/access/brin_internal.h +116 -0
  17. data/ext/pg_query/include/postgres/access/brin_tuple.h +112 -0
  18. data/ext/pg_query/include/postgres/access/clog.h +2 -3
  19. data/ext/pg_query/include/postgres/access/commit_ts.h +2 -3
  20. data/ext/pg_query/include/postgres/access/detoast.h +1 -1
  21. data/ext/pg_query/include/postgres/access/genam.h +8 -4
  22. data/ext/pg_query/include/postgres/access/gin.h +1 -1
  23. data/ext/pg_query/include/postgres/access/htup.h +1 -1
  24. data/ext/pg_query/include/postgres/access/htup_details.h +11 -11
  25. data/ext/pg_query/include/postgres/access/itup.h +3 -3
  26. data/ext/pg_query/include/postgres/access/parallel.h +1 -2
  27. data/ext/pg_query/include/postgres/access/printtup.h +1 -1
  28. data/ext/pg_query/include/postgres/access/relation.h +1 -1
  29. data/ext/pg_query/include/postgres/access/relscan.h +1 -1
  30. data/ext/pg_query/include/postgres/access/rmgrlist.h +1 -1
  31. data/ext/pg_query/include/postgres/access/sdir.h +1 -1
  32. data/ext/pg_query/include/postgres/access/skey.h +1 -1
  33. data/ext/pg_query/include/postgres/access/slru.h +221 -0
  34. data/ext/pg_query/include/postgres/access/stratnum.h +1 -1
  35. data/ext/pg_query/include/postgres/access/sysattr.h +1 -1
  36. data/ext/pg_query/include/postgres/access/table.h +1 -1
  37. data/ext/pg_query/include/postgres/access/tableam.h +33 -24
  38. data/ext/pg_query/include/postgres/access/tidstore.h +50 -0
  39. data/ext/pg_query/include/postgres/access/toast_compression.h +2 -2
  40. data/ext/pg_query/include/postgres/access/transam.h +7 -7
  41. data/ext/pg_query/include/postgres/access/tsmapi.h +1 -1
  42. data/ext/pg_query/include/postgres/access/tupconvert.h +1 -1
  43. data/ext/pg_query/include/postgres/access/tupdesc.h +5 -5
  44. data/ext/pg_query/include/postgres/access/tupmacs.h +1 -1
  45. data/ext/pg_query/include/postgres/access/twophase.h +2 -2
  46. data/ext/pg_query/include/postgres/access/xact.h +5 -5
  47. data/ext/pg_query/include/postgres/access/xlog.h +20 -12
  48. data/ext/pg_query/include/postgres/access/xlog_internal.h +4 -3
  49. data/ext/pg_query/include/postgres/access/xlogbackup.h +3 -1
  50. data/ext/pg_query/include/postgres/access/xlogdefs.h +5 -5
  51. data/ext/pg_query/include/postgres/access/xlogprefetcher.h +2 -2
  52. data/ext/pg_query/include/postgres/access/xlogreader.h +2 -2
  53. data/ext/pg_query/include/postgres/access/xlogrecord.h +3 -3
  54. data/ext/pg_query/include/postgres/access/xlogrecovery.h +4 -4
  55. data/ext/pg_query/include/postgres/archive/archive_module.h +9 -1
  56. data/ext/pg_query/include/postgres/c.h +31 -36
  57. data/ext/pg_query/include/postgres/catalog/catalog.h +3 -1
  58. data/ext/pg_query/include/postgres/catalog/catversion.h +2 -2
  59. data/ext/pg_query/include/postgres/catalog/dependency.h +17 -59
  60. data/ext/pg_query/include/postgres/catalog/genbki.h +12 -6
  61. data/ext/pg_query/include/postgres/catalog/index.h +22 -18
  62. data/ext/pg_query/include/postgres/catalog/indexing.h +1 -1
  63. data/ext/pg_query/include/postgres/catalog/namespace.h +18 -19
  64. data/ext/pg_query/include/postgres/catalog/objectaccess.h +2 -2
  65. data/ext/pg_query/include/postgres/catalog/objectaddress.h +1 -1
  66. data/ext/pg_query/include/postgres/catalog/pg_aggregate.h +4 -2
  67. data/ext/pg_query/include/postgres/catalog/pg_aggregate_d.h +1 -1
  68. data/ext/pg_query/include/postgres/catalog/pg_am.h +6 -3
  69. data/ext/pg_query/include/postgres/catalog/pg_am_d.h +1 -1
  70. data/ext/pg_query/include/postgres/catalog/pg_attribute.h +31 -14
  71. data/ext/pg_query/include/postgres/catalog/pg_attribute_d.h +3 -3
  72. data/ext/pg_query/include/postgres/catalog/pg_authid.h +6 -3
  73. data/ext/pg_query/include/postgres/catalog/pg_authid_d.h +2 -1
  74. data/ext/pg_query/include/postgres/catalog/pg_class.h +10 -5
  75. data/ext/pg_query/include/postgres/catalog/pg_class_d.h +4 -2
  76. data/ext/pg_query/include/postgres/catalog/pg_collation.h +11 -5
  77. data/ext/pg_query/include/postgres/catalog/pg_collation_d.h +5 -2
  78. data/ext/pg_query/include/postgres/catalog/pg_constraint.h +15 -10
  79. data/ext/pg_query/include/postgres/catalog/pg_constraint_d.h +2 -1
  80. data/ext/pg_query/include/postgres/catalog/pg_control.h +5 -3
  81. data/ext/pg_query/include/postgres/catalog/pg_conversion.h +8 -4
  82. data/ext/pg_query/include/postgres/catalog/pg_conversion_d.h +1 -1
  83. data/ext/pg_query/include/postgres/catalog/pg_database.h +9 -4
  84. data/ext/pg_query/include/postgres/catalog/pg_database_d.h +13 -12
  85. data/ext/pg_query/include/postgres/catalog/pg_depend.h +3 -3
  86. data/ext/pg_query/include/postgres/catalog/pg_depend_d.h +1 -1
  87. data/ext/pg_query/include/postgres/catalog/pg_event_trigger.h +6 -3
  88. data/ext/pg_query/include/postgres/catalog/pg_event_trigger_d.h +1 -1
  89. data/ext/pg_query/include/postgres/catalog/pg_index.h +5 -3
  90. data/ext/pg_query/include/postgres/catalog/pg_index_d.h +1 -1
  91. data/ext/pg_query/include/postgres/catalog/pg_language.h +6 -3
  92. data/ext/pg_query/include/postgres/catalog/pg_language_d.h +1 -1
  93. data/ext/pg_query/include/postgres/catalog/pg_namespace.h +6 -3
  94. data/ext/pg_query/include/postgres/catalog/pg_namespace_d.h +1 -1
  95. data/ext/pg_query/include/postgres/catalog/pg_opclass.h +6 -3
  96. data/ext/pg_query/include/postgres/catalog/pg_opclass_d.h +1 -1
  97. data/ext/pg_query/include/postgres/catalog/pg_operator.h +20 -3
  98. data/ext/pg_query/include/postgres/catalog/pg_operator_d.h +1 -1
  99. data/ext/pg_query/include/postgres/catalog/pg_opfamily.h +6 -3
  100. data/ext/pg_query/include/postgres/catalog/pg_opfamily_d.h +1 -1
  101. data/ext/pg_query/include/postgres/catalog/pg_partitioned_table.h +4 -2
  102. data/ext/pg_query/include/postgres/catalog/pg_partitioned_table_d.h +1 -1
  103. data/ext/pg_query/include/postgres/catalog/pg_proc.h +6 -3
  104. data/ext/pg_query/include/postgres/catalog/pg_proc_d.h +1 -1
  105. data/ext/pg_query/include/postgres/catalog/pg_publication.h +6 -3
  106. data/ext/pg_query/include/postgres/catalog/pg_publication_d.h +1 -1
  107. data/ext/pg_query/include/postgres/catalog/pg_replication_origin.h +6 -3
  108. data/ext/pg_query/include/postgres/catalog/pg_replication_origin_d.h +1 -1
  109. data/ext/pg_query/include/postgres/catalog/pg_statistic.h +10 -4
  110. data/ext/pg_query/include/postgres/catalog/pg_statistic_d.h +7 -3
  111. data/ext/pg_query/include/postgres/catalog/pg_statistic_ext.h +10 -7
  112. data/ext/pg_query/include/postgres/catalog/pg_statistic_ext_d.h +3 -3
  113. data/ext/pg_query/include/postgres/catalog/pg_transform.h +6 -3
  114. data/ext/pg_query/include/postgres/catalog/pg_transform_d.h +1 -1
  115. data/ext/pg_query/include/postgres/catalog/pg_trigger.h +4 -4
  116. data/ext/pg_query/include/postgres/catalog/pg_trigger_d.h +1 -1
  117. data/ext/pg_query/include/postgres/catalog/pg_ts_config.h +6 -3
  118. data/ext/pg_query/include/postgres/catalog/pg_ts_config_d.h +1 -1
  119. data/ext/pg_query/include/postgres/catalog/pg_ts_dict.h +6 -3
  120. data/ext/pg_query/include/postgres/catalog/pg_ts_dict_d.h +1 -1
  121. data/ext/pg_query/include/postgres/catalog/pg_ts_parser.h +6 -3
  122. data/ext/pg_query/include/postgres/catalog/pg_ts_parser_d.h +1 -1
  123. data/ext/pg_query/include/postgres/catalog/pg_ts_template.h +6 -3
  124. data/ext/pg_query/include/postgres/catalog/pg_ts_template_d.h +1 -1
  125. data/ext/pg_query/include/postgres/catalog/pg_type.h +6 -3
  126. data/ext/pg_query/include/postgres/catalog/pg_type_d.h +1 -1
  127. data/ext/pg_query/include/postgres/catalog/storage.h +1 -1
  128. data/ext/pg_query/include/postgres/catalog/syscache_ids.h +104 -0
  129. data/ext/pg_query/include/postgres/commands/async.h +2 -6
  130. data/ext/pg_query/include/postgres/commands/dbcommands.h +1 -1
  131. data/ext/pg_query/include/postgres/commands/defrem.h +6 -6
  132. data/ext/pg_query/include/postgres/commands/event_trigger.h +5 -2
  133. data/ext/pg_query/include/postgres/commands/explain.h +19 -3
  134. data/ext/pg_query/include/postgres/commands/prepare.h +1 -1
  135. data/ext/pg_query/include/postgres/commands/tablespace.h +1 -1
  136. data/ext/pg_query/include/postgres/commands/trigger.h +1 -1
  137. data/ext/pg_query/include/postgres/commands/vacuum.h +28 -26
  138. data/ext/pg_query/include/postgres/common/cryptohash.h +2 -2
  139. data/ext/pg_query/include/postgres/common/file_perm.h +1 -1
  140. data/ext/pg_query/include/postgres/common/file_utils.h +65 -0
  141. data/ext/pg_query/include/postgres/common/hashfn.h +16 -1
  142. data/ext/pg_query/include/postgres/common/hashfn_unstable.h +453 -0
  143. data/ext/pg_query/include/postgres/common/int.h +79 -4
  144. data/ext/pg_query/include/postgres/common/keywords.h +1 -1
  145. data/ext/pg_query/include/postgres/common/kwlookup.h +1 -1
  146. data/ext/pg_query/include/postgres/common/pg_prng.h +2 -1
  147. data/ext/pg_query/include/postgres/common/relpath.h +4 -4
  148. data/ext/pg_query/include/postgres/common/scram-common.h +1 -1
  149. data/ext/pg_query/include/postgres/common/sha2.h +1 -1
  150. data/ext/pg_query/include/postgres/common/string.h +1 -1
  151. data/ext/pg_query/include/postgres/common/unicode_east_asian_fw_table.h +2 -3
  152. data/ext/pg_query/include/postgres/copyfuncs.funcs.c +278 -30
  153. data/ext/pg_query/include/postgres/copyfuncs.switch.c +55 -4
  154. data/ext/pg_query/include/postgres/datatype/timestamp.h +28 -2
  155. data/ext/pg_query/include/postgres/equalfuncs.funcs.c +239 -26
  156. data/ext/pg_query/include/postgres/equalfuncs.switch.c +55 -4
  157. data/ext/pg_query/include/postgres/executor/execdesc.h +1 -1
  158. data/ext/pg_query/include/postgres/executor/executor.h +6 -5
  159. data/ext/pg_query/include/postgres/executor/functions.h +2 -1
  160. data/ext/pg_query/include/postgres/executor/instrument.h +5 -3
  161. data/ext/pg_query/include/postgres/executor/spi.h +2 -8
  162. data/ext/pg_query/include/postgres/executor/tablefunc.h +1 -1
  163. data/ext/pg_query/include/postgres/executor/tuptable.h +31 -2
  164. data/ext/pg_query/include/postgres/fmgr.h +2 -2
  165. data/ext/pg_query/include/postgres/foreign/fdwapi.h +1 -1
  166. data/ext/pg_query/include/postgres/funcapi.h +2 -2
  167. data/ext/pg_query/include/postgres/gram.h +871 -830
  168. data/ext/pg_query/include/postgres/gramparse.h +1 -1
  169. data/ext/pg_query/include/postgres/jit/jit.h +4 -3
  170. data/ext/pg_query/include/postgres/kwlist_d.h +511 -466
  171. data/ext/pg_query/include/postgres/lib/dshash.h +25 -10
  172. data/ext/pg_query/include/postgres/lib/ilist.h +1 -1
  173. data/ext/pg_query/include/postgres/lib/pairingheap.h +1 -1
  174. data/ext/pg_query/include/postgres/lib/simplehash.h +40 -18
  175. data/ext/pg_query/include/postgres/lib/sort_template.h +14 -1
  176. data/ext/pg_query/include/postgres/lib/stringinfo.h +93 -11
  177. data/ext/pg_query/include/postgres/libpq/auth.h +1 -1
  178. data/ext/pg_query/include/postgres/libpq/crypt.h +2 -2
  179. data/ext/pg_query/include/postgres/libpq/hba.h +4 -4
  180. data/ext/pg_query/include/postgres/libpq/libpq-be.h +29 -25
  181. data/ext/pg_query/include/postgres/libpq/libpq.h +6 -7
  182. data/ext/pg_query/include/postgres/libpq/pqcomm.h +26 -20
  183. data/ext/pg_query/include/postgres/libpq/pqformat.h +2 -3
  184. data/ext/pg_query/include/postgres/libpq/pqsignal.h +1 -1
  185. data/ext/pg_query/include/postgres/libpq/protocol.h +89 -0
  186. data/ext/pg_query/include/postgres/libpq/sasl.h +1 -1
  187. data/ext/pg_query/include/postgres/libpq/scram.h +1 -1
  188. data/ext/pg_query/include/postgres/mb/pg_wchar.h +102 -82
  189. data/ext/pg_query/include/postgres/mb/stringinfo_mb.h +1 -1
  190. data/ext/pg_query/include/postgres/miscadmin.h +64 -52
  191. data/ext/pg_query/include/postgres/nodes/bitmapset.h +17 -3
  192. data/ext/pg_query/include/postgres/nodes/execnodes.h +109 -25
  193. data/ext/pg_query/include/postgres/nodes/extensible.h +1 -1
  194. data/ext/pg_query/include/postgres/nodes/lockoptions.h +4 -4
  195. data/ext/pg_query/include/postgres/nodes/makefuncs.h +8 -2
  196. data/ext/pg_query/include/postgres/nodes/memnodes.h +43 -4
  197. data/ext/pg_query/include/postgres/nodes/miscnodes.h +1 -1
  198. data/ext/pg_query/include/postgres/nodes/nodeFuncs.h +1 -1
  199. data/ext/pg_query/include/postgres/nodes/nodes.h +30 -41
  200. data/ext/pg_query/include/postgres/nodes/nodetags.h +464 -444
  201. data/ext/pg_query/include/postgres/nodes/params.h +1 -1
  202. data/ext/pg_query/include/postgres/nodes/parsenodes.h +358 -175
  203. data/ext/pg_query/include/postgres/nodes/pathnodes.h +60 -9
  204. data/ext/pg_query/include/postgres/nodes/pg_list.h +62 -11
  205. data/ext/pg_query/include/postgres/nodes/plannodes.h +11 -10
  206. data/ext/pg_query/include/postgres/nodes/primnodes.h +344 -50
  207. data/ext/pg_query/include/postgres/nodes/print.h +1 -1
  208. data/ext/pg_query/include/postgres/nodes/queryjumble.h +2 -2
  209. data/ext/pg_query/include/postgres/nodes/replnodes.h +23 -2
  210. data/ext/pg_query/include/postgres/nodes/supportnodes.h +1 -1
  211. data/ext/pg_query/include/postgres/nodes/tidbitmap.h +1 -1
  212. data/ext/pg_query/include/postgres/nodes/value.h +1 -1
  213. data/ext/pg_query/include/postgres/optimizer/cost.h +5 -4
  214. data/ext/pg_query/include/postgres/optimizer/geqo.h +1 -1
  215. data/ext/pg_query/include/postgres/optimizer/geqo_gene.h +1 -1
  216. data/ext/pg_query/include/postgres/optimizer/optimizer.h +5 -2
  217. data/ext/pg_query/include/postgres/optimizer/paths.h +13 -8
  218. data/ext/pg_query/include/postgres/optimizer/planmain.h +7 -1
  219. data/ext/pg_query/include/postgres/parser/analyze.h +3 -1
  220. data/ext/pg_query/include/postgres/parser/kwlist.h +22 -2
  221. data/ext/pg_query/include/postgres/parser/parse_agg.h +1 -1
  222. data/ext/pg_query/include/postgres/parser/parse_coerce.h +2 -2
  223. data/ext/pg_query/include/postgres/parser/parse_expr.h +1 -1
  224. data/ext/pg_query/include/postgres/parser/parse_func.h +2 -2
  225. data/ext/pg_query/include/postgres/parser/parse_node.h +3 -2
  226. data/ext/pg_query/include/postgres/parser/parse_oper.h +4 -1
  227. data/ext/pg_query/include/postgres/parser/parse_relation.h +1 -1
  228. data/ext/pg_query/include/postgres/parser/parse_type.h +2 -2
  229. data/ext/pg_query/include/postgres/parser/parser.h +3 -3
  230. data/ext/pg_query/include/postgres/parser/parsetree.h +1 -1
  231. data/ext/pg_query/include/postgres/parser/scanner.h +1 -1
  232. data/ext/pg_query/include/postgres/parser/scansup.h +1 -1
  233. data/ext/pg_query/include/postgres/partitioning/partdefs.h +1 -1
  234. data/ext/pg_query/include/postgres/pg_config.h +34 -34
  235. data/ext/pg_query/include/postgres/pg_config_manual.h +21 -8
  236. data/ext/pg_query/include/postgres/pg_getopt.h +1 -1
  237. data/ext/pg_query/include/postgres/pg_trace.h +1 -1
  238. data/ext/pg_query/include/postgres/pgstat.h +13 -11
  239. data/ext/pg_query/include/postgres/pgtime.h +1 -1
  240. data/ext/pg_query/include/postgres/pl_reserved_kwlist.h +1 -1
  241. data/ext/pg_query/include/postgres/pl_reserved_kwlist_d.h +1 -1
  242. data/ext/pg_query/include/postgres/pl_unreserved_kwlist.h +1 -1
  243. data/ext/pg_query/include/postgres/pl_unreserved_kwlist_d.h +1 -1
  244. data/ext/pg_query/include/postgres/plerrcodes.h +4 -4
  245. data/ext/pg_query/include/postgres/plpgsql.h +15 -13
  246. data/ext/pg_query/include/postgres/port/atomics/arch-arm.h +1 -1
  247. data/ext/pg_query/include/postgres/port/atomics/arch-hppa.h +1 -1
  248. data/ext/pg_query/include/postgres/port/atomics/arch-ppc.h +3 -1
  249. data/ext/pg_query/include/postgres/port/atomics/arch-x86.h +3 -1
  250. data/ext/pg_query/include/postgres/port/atomics/fallback.h +1 -1
  251. data/ext/pg_query/include/postgres/port/atomics/generic-gcc.h +38 -1
  252. data/ext/pg_query/include/postgres/port/atomics/generic-msvc.h +19 -1
  253. data/ext/pg_query/include/postgres/port/atomics/generic-sunpro.h +16 -1
  254. data/ext/pg_query/include/postgres/port/atomics/generic.h +38 -2
  255. data/ext/pg_query/include/postgres/port/atomics.h +93 -6
  256. data/ext/pg_query/include/postgres/port/pg_bitutils.h +91 -9
  257. data/ext/pg_query/include/postgres/port/pg_bswap.h +1 -1
  258. data/ext/pg_query/include/postgres/port/pg_crc32c.h +10 -1
  259. data/ext/pg_query/include/postgres/port/pg_iovec.h +117 -0
  260. data/ext/pg_query/include/postgres/port/simd.h +48 -1
  261. data/ext/pg_query/include/postgres/port/win32/sys/socket.h +8 -0
  262. data/ext/pg_query/include/postgres/port/win32_port.h +1 -11
  263. data/ext/pg_query/include/postgres/port.h +7 -3
  264. data/ext/pg_query/include/postgres/portability/instr_time.h +1 -1
  265. data/ext/pg_query/include/postgres/postgres.h +1 -1
  266. data/ext/pg_query/include/postgres/postmaster/autovacuum.h +5 -16
  267. data/ext/pg_query/include/postgres/postmaster/bgworker.h +8 -6
  268. data/ext/pg_query/include/postgres/postmaster/bgworker_internals.h +3 -7
  269. data/ext/pg_query/include/postgres/postmaster/bgwriter.h +3 -3
  270. data/ext/pg_query/include/postgres/postmaster/interrupt.h +1 -1
  271. data/ext/pg_query/include/postgres/postmaster/pgarch.h +2 -2
  272. data/ext/pg_query/include/postgres/postmaster/postmaster.h +25 -5
  273. data/ext/pg_query/include/postgres/postmaster/startup.h +2 -2
  274. data/ext/pg_query/include/postgres/postmaster/syslogger.h +2 -4
  275. data/ext/pg_query/include/postgres/postmaster/walsummarizer.h +35 -0
  276. data/ext/pg_query/include/postgres/postmaster/walwriter.h +2 -2
  277. data/ext/pg_query/include/postgres/regex/regex.h +92 -9
  278. data/ext/pg_query/include/postgres/replication/logicallauncher.h +1 -1
  279. data/ext/pg_query/include/postgres/replication/logicalproto.h +2 -2
  280. data/ext/pg_query/include/postgres/replication/logicalworker.h +2 -1
  281. data/ext/pg_query/include/postgres/replication/origin.h +1 -1
  282. data/ext/pg_query/include/postgres/replication/reorderbuffer.h +18 -28
  283. data/ext/pg_query/include/postgres/replication/slot.h +41 -5
  284. data/ext/pg_query/include/postgres/replication/slotsync.h +38 -0
  285. data/ext/pg_query/include/postgres/replication/syncrep.h +1 -1
  286. data/ext/pg_query/include/postgres/replication/walreceiver.h +37 -11
  287. data/ext/pg_query/include/postgres/replication/walsender.h +5 -3
  288. data/ext/pg_query/include/postgres/rewrite/prs2lock.h +1 -1
  289. data/ext/pg_query/include/postgres/rewrite/rewriteHandler.h +7 -1
  290. data/ext/pg_query/include/postgres/rewrite/rewriteManip.h +2 -2
  291. data/ext/pg_query/include/postgres/rewrite/rewriteSupport.h +1 -1
  292. data/ext/pg_query/include/postgres/storage/block.h +1 -1
  293. data/ext/pg_query/include/postgres/storage/buf.h +1 -1
  294. data/ext/pg_query/include/postgres/storage/bufmgr.h +59 -41
  295. data/ext/pg_query/include/postgres/storage/bufpage.h +1 -1
  296. data/ext/pg_query/include/postgres/storage/condition_variable.h +1 -1
  297. data/ext/pg_query/include/postgres/storage/dsm.h +1 -1
  298. data/ext/pg_query/include/postgres/storage/dsm_impl.h +2 -2
  299. data/ext/pg_query/include/postgres/storage/fd.h +30 -13
  300. data/ext/pg_query/include/postgres/storage/fileset.h +1 -1
  301. data/ext/pg_query/include/postgres/storage/ipc.h +4 -1
  302. data/ext/pg_query/include/postgres/storage/item.h +1 -1
  303. data/ext/pg_query/include/postgres/storage/itemid.h +1 -1
  304. data/ext/pg_query/include/postgres/storage/itemptr.h +1 -1
  305. data/ext/pg_query/include/postgres/storage/large_object.h +1 -1
  306. data/ext/pg_query/include/postgres/storage/latch.h +4 -2
  307. data/ext/pg_query/include/postgres/storage/lmgr.h +8 -2
  308. data/ext/pg_query/include/postgres/storage/lock.h +19 -19
  309. data/ext/pg_query/include/postgres/storage/lockdefs.h +1 -1
  310. data/ext/pg_query/include/postgres/storage/lwlock.h +17 -9
  311. data/ext/pg_query/include/postgres/storage/lwlocknames.h +7 -10
  312. data/ext/pg_query/include/postgres/storage/off.h +1 -1
  313. data/ext/pg_query/include/postgres/storage/pg_sema.h +1 -1
  314. data/ext/pg_query/include/postgres/storage/pg_shmem.h +5 -4
  315. data/ext/pg_query/include/postgres/storage/pmsignal.h +2 -2
  316. data/ext/pg_query/include/postgres/storage/predicate.h +1 -5
  317. data/ext/pg_query/include/postgres/storage/proc.h +48 -23
  318. data/ext/pg_query/include/postgres/storage/procarray.h +5 -1
  319. data/ext/pg_query/include/postgres/storage/proclist_types.h +11 -9
  320. data/ext/pg_query/include/postgres/storage/procnumber.h +43 -0
  321. data/ext/pg_query/include/postgres/storage/procsignal.h +8 -6
  322. data/ext/pg_query/include/postgres/storage/read_stream.h +65 -0
  323. data/ext/pg_query/include/postgres/storage/relfilelocator.h +16 -15
  324. data/ext/pg_query/include/postgres/storage/s_lock.h +7 -27
  325. data/ext/pg_query/include/postgres/storage/sharedfileset.h +1 -1
  326. data/ext/pg_query/include/postgres/storage/shm_mq.h +2 -2
  327. data/ext/pg_query/include/postgres/storage/shm_toc.h +1 -1
  328. data/ext/pg_query/include/postgres/storage/shmem.h +1 -1
  329. data/ext/pg_query/include/postgres/storage/sinval.h +3 -3
  330. data/ext/pg_query/include/postgres/storage/smgr.h +41 -27
  331. data/ext/pg_query/include/postgres/storage/spin.h +1 -1
  332. data/ext/pg_query/include/postgres/storage/standby.h +13 -3
  333. data/ext/pg_query/include/postgres/storage/standbydefs.h +2 -2
  334. data/ext/pg_query/include/postgres/storage/sync.h +4 -4
  335. data/ext/pg_query/include/postgres/tcop/cmdtag.h +1 -2
  336. data/ext/pg_query/include/postgres/tcop/cmdtaglist.h +3 -2
  337. data/ext/pg_query/include/postgres/tcop/deparse_utility.h +2 -2
  338. data/ext/pg_query/include/postgres/tcop/dest.h +3 -2
  339. data/ext/pg_query/include/postgres/tcop/fastpath.h +1 -1
  340. data/ext/pg_query/include/postgres/tcop/pquery.h +1 -1
  341. data/ext/pg_query/include/postgres/tcop/tcopprot.h +9 -5
  342. data/ext/pg_query/include/postgres/tcop/utility.h +2 -2
  343. data/ext/pg_query/include/postgres/tsearch/ts_cache.h +1 -1
  344. data/ext/pg_query/include/postgres/utils/acl.h +19 -7
  345. data/ext/pg_query/include/postgres/utils/aclchk_internal.h +1 -1
  346. data/ext/pg_query/include/postgres/utils/array.h +1 -2
  347. data/ext/pg_query/include/postgres/utils/ascii.h +84 -0
  348. data/ext/pg_query/include/postgres/utils/backend_progress.h +3 -2
  349. data/ext/pg_query/include/postgres/utils/backend_status.h +8 -10
  350. data/ext/pg_query/include/postgres/utils/builtins.h +4 -1
  351. data/ext/pg_query/include/postgres/utils/bytea.h +2 -2
  352. data/ext/pg_query/include/postgres/utils/catcache.h +5 -6
  353. data/ext/pg_query/include/postgres/utils/date.h +1 -1
  354. data/ext/pg_query/include/postgres/utils/datetime.h +4 -1
  355. data/ext/pg_query/include/postgres/utils/datum.h +1 -1
  356. data/ext/pg_query/include/postgres/utils/dsa.h +44 -5
  357. data/ext/pg_query/include/postgres/utils/elog.h +3 -8
  358. data/ext/pg_query/include/postgres/utils/errcodes.h +1 -3
  359. data/ext/pg_query/include/postgres/utils/expandeddatum.h +1 -1
  360. data/ext/pg_query/include/postgres/utils/expandedrecord.h +1 -1
  361. data/ext/pg_query/include/postgres/utils/float.h +1 -1
  362. data/ext/pg_query/include/postgres/utils/fmgroids.h +49 -16
  363. data/ext/pg_query/include/postgres/utils/fmgrprotos.h +47 -14
  364. data/ext/pg_query/include/postgres/utils/fmgrtab.h +1 -1
  365. data/ext/pg_query/include/postgres/utils/guc.h +20 -6
  366. data/ext/pg_query/include/postgres/utils/guc_hooks.h +23 -2
  367. data/ext/pg_query/include/postgres/utils/guc_tables.h +6 -5
  368. data/ext/pg_query/include/postgres/utils/hsearch.h +2 -2
  369. data/ext/pg_query/include/postgres/utils/injection_point.h +44 -0
  370. data/ext/pg_query/include/postgres/utils/inval.h +1 -1
  371. data/ext/pg_query/include/postgres/utils/logtape.h +5 -5
  372. data/ext/pg_query/include/postgres/utils/lsyscache.h +6 -3
  373. data/ext/pg_query/include/postgres/utils/memdebug.h +1 -1
  374. data/ext/pg_query/include/postgres/utils/memutils.h +12 -5
  375. data/ext/pg_query/include/postgres/utils/memutils_internal.h +53 -13
  376. data/ext/pg_query/include/postgres/utils/memutils_memorychunk.h +25 -9
  377. data/ext/pg_query/include/postgres/utils/numeric.h +6 -1
  378. data/ext/pg_query/include/postgres/utils/palloc.h +1 -15
  379. data/ext/pg_query/include/postgres/utils/partcache.h +1 -1
  380. data/ext/pg_query/include/postgres/utils/pg_locale.h +8 -7
  381. data/ext/pg_query/include/postgres/utils/pgstat_internal.h +11 -17
  382. data/ext/pg_query/include/postgres/utils/plancache.h +5 -3
  383. data/ext/pg_query/include/postgres/utils/portal.h +9 -9
  384. data/ext/pg_query/include/postgres/utils/queryenvironment.h +2 -2
  385. data/ext/pg_query/include/postgres/utils/regproc.h +1 -1
  386. data/ext/pg_query/include/postgres/utils/rel.h +14 -15
  387. data/ext/pg_query/include/postgres/utils/relcache.h +2 -5
  388. data/ext/pg_query/include/postgres/utils/reltrigger.h +1 -1
  389. data/ext/pg_query/include/postgres/utils/resowner.h +90 -9
  390. data/ext/pg_query/include/postgres/utils/ruleutils.h +1 -1
  391. data/ext/pg_query/include/postgres/utils/sharedtuplestore.h +1 -1
  392. data/ext/pg_query/include/postgres/utils/snapmgr.h +1 -52
  393. data/ext/pg_query/include/postgres/utils/snapshot.h +2 -2
  394. data/ext/pg_query/include/postgres/utils/sortsupport.h +1 -1
  395. data/ext/pg_query/include/postgres/utils/syscache.h +2 -98
  396. data/ext/pg_query/include/postgres/utils/timeout.h +3 -2
  397. data/ext/pg_query/include/postgres/utils/timestamp.h +1 -1
  398. data/ext/pg_query/include/postgres/utils/tuplesort.h +36 -9
  399. data/ext/pg_query/include/postgres/utils/tuplestore.h +2 -5
  400. data/ext/pg_query/include/postgres/utils/typcache.h +2 -1
  401. data/ext/pg_query/include/postgres/utils/varlena.h +1 -1
  402. data/ext/pg_query/include/postgres/utils/wait_event.h +28 -214
  403. data/ext/pg_query/include/postgres/utils/wait_event_types.h +218 -0
  404. data/ext/pg_query/include/postgres/utils/xml.h +4 -4
  405. data/ext/pg_query/include/postgres/varatt.h +1 -1
  406. data/ext/pg_query/include/protobuf/pg_query.pb-c.h +1546 -792
  407. data/ext/pg_query/include/protobuf/pg_query.pb.h +58365 -46595
  408. data/ext/pg_query/pg_query.pb-c.c +6598 -3739
  409. data/ext/pg_query/pg_query_normalize.c +42 -1
  410. data/ext/pg_query/pg_query_outfuncs_json.c +3 -1
  411. data/ext/pg_query/pg_query_parse_plpgsql.c +12 -13
  412. data/ext/pg_query/pg_query_readfuncs_protobuf.c +2 -2
  413. data/ext/pg_query/pg_query_ruby_freebsd.sym +0 -1
  414. data/ext/pg_query/pg_query_scan.c +1 -1
  415. data/ext/pg_query/postgres_deparse.c +409 -21
  416. data/ext/pg_query/src_backend_catalog_namespace.c +241 -66
  417. data/ext/pg_query/src_backend_catalog_pg_proc.c +1 -3
  418. data/ext/pg_query/src_backend_commands_define.c +2 -3
  419. data/ext/pg_query/src_backend_nodes_bitmapset.c +137 -94
  420. data/ext/pg_query/src_backend_nodes_copyfuncs.c +1 -1
  421. data/ext/pg_query/src_backend_nodes_equalfuncs.c +1 -1
  422. data/ext/pg_query/src_backend_nodes_extensible.c +1 -1
  423. data/ext/pg_query/src_backend_nodes_list.c +3 -7
  424. data/ext/pg_query/src_backend_nodes_makefuncs.c +59 -20
  425. data/ext/pg_query/src_backend_nodes_nodeFuncs.c +109 -2
  426. data/ext/pg_query/src_backend_nodes_value.c +1 -1
  427. data/ext/pg_query/src_backend_parser_gram.c +34490 -32135
  428. data/ext/pg_query/src_backend_parser_parser.c +8 -8
  429. data/ext/pg_query/src_backend_parser_scan.c +5637 -3028
  430. data/ext/pg_query/src_backend_parser_scansup.c +2 -1
  431. data/ext/pg_query/src_backend_storage_ipc_ipc.c +1 -1
  432. data/ext/pg_query/src_backend_tcop_postgres.c +34 -10
  433. data/ext/pg_query/src_backend_utils_activity_pgstat_database.c +2 -2
  434. data/ext/pg_query/src_backend_utils_adt_datum.c +8 -6
  435. data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +1 -1
  436. data/ext/pg_query/src_backend_utils_adt_format_type.c +1 -1
  437. data/ext/pg_query/src_backend_utils_adt_numutils.c +4 -5
  438. data/ext/pg_query/src_backend_utils_adt_ruleutils.c +101 -28
  439. data/ext/pg_query/src_backend_utils_error_assert.c +1 -1
  440. data/ext/pg_query/src_backend_utils_error_elog.c +47 -42
  441. data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +4 -2
  442. data/ext/pg_query/src_backend_utils_init_globals.c +15 -3
  443. data/ext/pg_query/src_backend_utils_mb_mbutils.c +11 -18
  444. data/ext/pg_query/src_backend_utils_misc_guc_tables.c +16 -6
  445. data/ext/pg_query/src_backend_utils_mmgr_alignedalloc.c +8 -5
  446. data/ext/pg_query/src_backend_utils_mmgr_aset.c +308 -238
  447. data/ext/pg_query/src_backend_utils_mmgr_bump.c +728 -0
  448. data/ext/pg_query/src_backend_utils_mmgr_generation.c +273 -197
  449. data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +270 -215
  450. data/ext/pg_query/src_backend_utils_mmgr_slab.c +154 -96
  451. data/ext/pg_query/src_common_encnames.c +43 -44
  452. data/ext/pg_query/src_common_hashfn.c +1 -1
  453. data/ext/pg_query/src_common_keywords.c +1 -1
  454. data/ext/pg_query/src_common_kwlist_d.h +511 -466
  455. data/ext/pg_query/src_common_kwlookup.c +1 -1
  456. data/ext/pg_query/src_common_psprintf.c +3 -3
  457. data/ext/pg_query/src_common_stringinfo.c +18 -1
  458. data/ext/pg_query/src_common_wchar.c +45 -108
  459. data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +99 -5
  460. data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +1 -1
  461. data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +242 -143
  462. data/ext/pg_query/src_pl_plpgsql_src_pl_handler.c +1 -1
  463. data/ext/pg_query/src_pl_plpgsql_src_pl_reserved_kwlist_d.h +1 -1
  464. data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +19 -1
  465. data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +1 -1
  466. data/ext/pg_query/src_port_pg_bitutils.c +173 -28
  467. data/ext/pg_query/src_port_pgstrcasecmp.c +29 -1
  468. data/ext/pg_query/src_port_snprintf.c +1 -1
  469. data/ext/pg_query/src_port_strerror.c +1 -3
  470. data/ext/pg_query/src_port_strlcpy.c +1 -1
  471. data/lib/pg_query/param_refs.rb +1 -1
  472. data/lib/pg_query/pg_query_pb.rb +26 -3
  473. data/lib/pg_query/treewalker.rb +38 -11
  474. data/lib/pg_query/truncate.rb +1 -1
  475. data/lib/pg_query/version.rb +1 -1
  476. metadata +25 -11
  477. data/ext/pg_query/include/postgres/storage/backendid.h +0 -37
  478. data/ext/pg_query/include/postgres/storage/sinvaladt.h +0 -45
  479. data/ext/pg_query/src_backend_nodes_nodes.c +0 -38
@@ -7,7 +7,7 @@
7
7
  * and join trees.
8
8
  *
9
9
  *
10
- * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
10
+ * Portions Copyright (c) 1996-2024, 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
@@ -22,6 +22,14 @@
22
22
  #include "nodes/pg_list.h"
23
23
 
24
24
 
25
+ typedef enum OverridingKind
26
+ {
27
+ OVERRIDING_NOT_SET = 0,
28
+ OVERRIDING_USER_VALUE,
29
+ OVERRIDING_SYSTEM_VALUE,
30
+ } OverridingKind;
31
+
32
+
25
33
  /* ----------------------------------------------------------------
26
34
  * node definitions
27
35
  * ----------------------------------------------------------------
@@ -49,7 +57,7 @@ typedef enum OnCommitAction
49
57
  ONCOMMIT_NOOP, /* No ON COMMIT clause (do nothing) */
50
58
  ONCOMMIT_PRESERVE_ROWS, /* ON COMMIT PRESERVE ROWS (do nothing) */
51
59
  ONCOMMIT_DELETE_ROWS, /* ON COMMIT DELETE ROWS */
52
- ONCOMMIT_DROP /* ON COMMIT DROP */
60
+ ONCOMMIT_DROP, /* ON COMMIT DROP */
53
61
  } OnCommitAction;
54
62
 
55
63
  /*
@@ -83,11 +91,17 @@ typedef struct RangeVar
83
91
  Alias *alias;
84
92
 
85
93
  /* token location, or -1 if unknown */
86
- int location;
94
+ ParseLoc location;
87
95
  } RangeVar;
88
96
 
97
+ typedef enum TableFuncType
98
+ {
99
+ TFT_XMLTABLE,
100
+ TFT_JSON_TABLE,
101
+ } TableFuncType;
102
+
89
103
  /*
90
- * TableFunc - node for a table function, such as XMLTABLE.
104
+ * TableFunc - node for a table function, such as XMLTABLE and JSON_TABLE.
91
105
  *
92
106
  * Entries in the ns_names list are either String nodes containing
93
107
  * literal namespace names, or NULL pointers to represent DEFAULT.
@@ -95,6 +109,8 @@ typedef struct RangeVar
95
109
  typedef struct TableFunc
96
110
  {
97
111
  NodeTag type;
112
+ /* XMLTABLE or JSON_TABLE */
113
+ TableFuncType functype;
98
114
  /* list of namespace URI expressions */
99
115
  List *ns_uris pg_node_attr(query_jumble_ignore);
100
116
  /* list of namespace names or NULL */
@@ -115,12 +131,18 @@ typedef struct TableFunc
115
131
  List *colexprs;
116
132
  /* list of column default expressions */
117
133
  List *coldefexprs pg_node_attr(query_jumble_ignore);
134
+ /* JSON_TABLE: list of column value expressions */
135
+ List *colvalexprs pg_node_attr(query_jumble_ignore);
136
+ /* JSON_TABLE: list of PASSING argument expressions */
137
+ List *passingvalexprs pg_node_attr(query_jumble_ignore);
118
138
  /* nullability flag for each output column */
119
139
  Bitmapset *notnulls pg_node_attr(query_jumble_ignore);
140
+ /* JSON_TABLE plan */
141
+ Node *plan pg_node_attr(query_jumble_ignore);
120
142
  /* counts from 0; -1 if none specified */
121
143
  int ordinalitycol pg_node_attr(query_jumble_ignore);
122
144
  /* token location, or -1 if unknown */
123
- int location;
145
+ ParseLoc location;
124
146
  } TableFunc;
125
147
 
126
148
  /*
@@ -268,7 +290,7 @@ typedef struct Var
268
290
  AttrNumber varattnosyn pg_node_attr(equal_ignore, query_jumble_ignore);
269
291
 
270
292
  /* token location, or -1 if unknown */
271
- int location;
293
+ ParseLoc location;
272
294
  } Var;
273
295
 
274
296
  /*
@@ -310,7 +332,7 @@ typedef struct Const
310
332
  * token location, or -1 if unknown. All constants are tracked as
311
333
  * locations in query jumbling, to be marked as parameters.
312
334
  */
313
- int location pg_node_attr(query_jumble_location);
335
+ ParseLoc location pg_node_attr(query_jumble_location);
314
336
  } Const;
315
337
 
316
338
  /*
@@ -345,7 +367,7 @@ typedef enum ParamKind
345
367
  PARAM_EXTERN,
346
368
  PARAM_EXEC,
347
369
  PARAM_SUBLINK,
348
- PARAM_MULTIEXPR
370
+ PARAM_MULTIEXPR,
349
371
  } ParamKind;
350
372
 
351
373
  typedef struct Param
@@ -359,7 +381,7 @@ typedef struct Param
359
381
  /* OID of collation, or InvalidOid if none */
360
382
  Oid paramcollid pg_node_attr(query_jumble_ignore);
361
383
  /* token location, or -1 if unknown */
362
- int location;
384
+ ParseLoc location;
363
385
  } Param;
364
386
 
365
387
  /*
@@ -482,7 +504,7 @@ typedef struct Aggref
482
504
  int aggtransno pg_node_attr(query_jumble_ignore);
483
505
 
484
506
  /* token location, or -1 if unknown */
485
- int location;
507
+ ParseLoc location;
486
508
  } Aggref;
487
509
 
488
510
  /*
@@ -529,7 +551,7 @@ typedef struct GroupingFunc
529
551
  Index agglevelsup;
530
552
 
531
553
  /* token location */
532
- int location;
554
+ ParseLoc location;
533
555
  } GroupingFunc;
534
556
 
535
557
  /*
@@ -553,6 +575,8 @@ typedef struct WindowFunc
553
575
  List *args;
554
576
  /* FILTER expression, if any */
555
577
  Expr *aggfilter;
578
+ /* List of WindowFuncRunConditions to help short-circuit execution */
579
+ List *runCondition pg_node_attr(query_jumble_ignore);
556
580
  /* index of associated WindowClause */
557
581
  Index winref;
558
582
  /* true if argument list was really '*' */
@@ -560,9 +584,58 @@ typedef struct WindowFunc
560
584
  /* is function a simple aggregate? */
561
585
  bool winagg pg_node_attr(query_jumble_ignore);
562
586
  /* token location, or -1 if unknown */
563
- int location;
587
+ ParseLoc location;
564
588
  } WindowFunc;
565
589
 
590
+ /*
591
+ * WindowFuncRunCondition
592
+ *
593
+ * Represents intermediate OpExprs which will be used by WindowAgg to
594
+ * short-circuit execution.
595
+ */
596
+ typedef struct WindowFuncRunCondition
597
+ {
598
+ Expr xpr;
599
+
600
+ /* PG_OPERATOR OID of the operator */
601
+ Oid opno;
602
+ /* OID of collation that operator should use */
603
+ Oid inputcollid pg_node_attr(query_jumble_ignore);
604
+
605
+ /*
606
+ * true of WindowFunc belongs on the left of the resulting OpExpr or false
607
+ * if the WindowFunc is on the right.
608
+ */
609
+ bool wfunc_left;
610
+
611
+ /*
612
+ * The Expr being compared to the WindowFunc to use in the OpExpr in the
613
+ * WindowAgg's runCondition
614
+ */
615
+ Expr *arg;
616
+ } WindowFuncRunCondition;
617
+
618
+ /*
619
+ * MergeSupportFunc
620
+ *
621
+ * A MergeSupportFunc is a merge support function expression that can only
622
+ * appear in the RETURNING list of a MERGE command. It returns information
623
+ * about the currently executing merge action.
624
+ *
625
+ * Currently, the only supported function is MERGE_ACTION(), which returns the
626
+ * command executed ("INSERT", "UPDATE", or "DELETE").
627
+ */
628
+ typedef struct MergeSupportFunc
629
+ {
630
+ Expr xpr;
631
+ /* type Oid of result */
632
+ Oid msftype;
633
+ /* OID of collation, or InvalidOid if none */
634
+ Oid msfcollid;
635
+ /* token location, or -1 if unknown */
636
+ ParseLoc location;
637
+ } MergeSupportFunc;
638
+
566
639
  /*
567
640
  * SubscriptingRef: describes a subscripting operation over a container
568
641
  * (array, etc).
@@ -641,7 +714,7 @@ typedef enum CoercionContext
641
714
  COERCION_IMPLICIT, /* coercion in context of expression */
642
715
  COERCION_ASSIGNMENT, /* coercion in context of assignment */
643
716
  COERCION_PLPGSQL, /* if no assignment cast, use CoerceViaIO */
644
- COERCION_EXPLICIT /* explicit cast operation */
717
+ COERCION_EXPLICIT, /* explicit cast operation */
645
718
  } CoercionContext;
646
719
 
647
720
  /*
@@ -661,7 +734,7 @@ typedef enum CoercionForm
661
734
  COERCE_EXPLICIT_CALL, /* display as a function call */
662
735
  COERCE_EXPLICIT_CAST, /* display as an explicit cast */
663
736
  COERCE_IMPLICIT_CAST, /* implicit cast, so hide it */
664
- COERCE_SQL_SYNTAX /* display with SQL-mandated special syntax */
737
+ COERCE_SQL_SYNTAX, /* display with SQL-mandated special syntax */
665
738
  } CoercionForm;
666
739
 
667
740
  /*
@@ -694,7 +767,7 @@ typedef struct FuncExpr
694
767
  /* arguments to the function */
695
768
  List *args;
696
769
  /* token location, or -1 if unknown */
697
- int location;
770
+ ParseLoc location;
698
771
  } FuncExpr;
699
772
 
700
773
  /*
@@ -721,7 +794,7 @@ typedef struct NamedArgExpr
721
794
  /* argument's number in positional notation */
722
795
  int argnumber;
723
796
  /* argument name location, or -1 if unknown */
724
- int location;
797
+ ParseLoc location;
725
798
  } NamedArgExpr;
726
799
 
727
800
  /*
@@ -763,7 +836,7 @@ typedef struct OpExpr
763
836
  List *args;
764
837
 
765
838
  /* token location, or -1 if unknown */
766
- int location;
839
+ ParseLoc location;
767
840
  } OpExpr;
768
841
 
769
842
  /*
@@ -843,7 +916,7 @@ typedef struct ScalarArrayOpExpr
843
916
  List *args;
844
917
 
845
918
  /* token location, or -1 if unknown */
846
- int location;
919
+ ParseLoc location;
847
920
  } ScalarArrayOpExpr;
848
921
 
849
922
  /*
@@ -865,7 +938,7 @@ typedef struct BoolExpr
865
938
  Expr xpr;
866
939
  BoolExprType boolop;
867
940
  List *args; /* arguments to this expression */
868
- int location; /* token location, or -1 if unknown */
941
+ ParseLoc location; /* token location, or -1 if unknown */
869
942
  } BoolExpr;
870
943
 
871
944
  /*
@@ -928,7 +1001,7 @@ typedef enum SubLinkType
928
1001
  EXPR_SUBLINK,
929
1002
  MULTIEXPR_SUBLINK,
930
1003
  ARRAY_SUBLINK,
931
- CTE_SUBLINK /* for SubPlans only */
1004
+ CTE_SUBLINK, /* for SubPlans only */
932
1005
  } SubLinkType;
933
1006
 
934
1007
 
@@ -942,7 +1015,7 @@ typedef struct SubLink
942
1015
  List *operName pg_node_attr(query_jumble_ignore);
943
1016
  /* subselect as Query* or raw parsetree */
944
1017
  Node *subselect;
945
- int location; /* token location, or -1 if unknown */
1018
+ ParseLoc location; /* token location, or -1 if unknown */
946
1019
  } SubLink;
947
1020
 
948
1021
  /*
@@ -1116,7 +1189,7 @@ typedef struct RelabelType
1116
1189
  Oid resultcollid pg_node_attr(query_jumble_ignore);
1117
1190
  /* how to display this node */
1118
1191
  CoercionForm relabelformat pg_node_attr(query_jumble_ignore);
1119
- int location; /* token location, or -1 if unknown */
1192
+ ParseLoc location; /* token location, or -1 if unknown */
1120
1193
  } RelabelType;
1121
1194
 
1122
1195
  /* ----------------
@@ -1138,7 +1211,7 @@ typedef struct CoerceViaIO
1138
1211
  Oid resultcollid pg_node_attr(query_jumble_ignore);
1139
1212
  /* how to display this node */
1140
1213
  CoercionForm coerceformat pg_node_attr(query_jumble_ignore);
1141
- int location; /* token location, or -1 if unknown */
1214
+ ParseLoc location; /* token location, or -1 if unknown */
1142
1215
  } CoerceViaIO;
1143
1216
 
1144
1217
  /* ----------------
@@ -1166,7 +1239,7 @@ typedef struct ArrayCoerceExpr
1166
1239
  Oid resultcollid pg_node_attr(query_jumble_ignore);
1167
1240
  /* how to display this node */
1168
1241
  CoercionForm coerceformat pg_node_attr(query_jumble_ignore);
1169
- int location; /* token location, or -1 if unknown */
1242
+ ParseLoc location; /* token location, or -1 if unknown */
1170
1243
  } ArrayCoerceExpr;
1171
1244
 
1172
1245
  /* ----------------
@@ -1190,7 +1263,7 @@ typedef struct ConvertRowtypeExpr
1190
1263
  /* Like RowExpr, we deliberately omit a typmod and collation here */
1191
1264
  /* how to display this node */
1192
1265
  CoercionForm convertformat pg_node_attr(query_jumble_ignore);
1193
- int location; /* token location, or -1 if unknown */
1266
+ ParseLoc location; /* token location, or -1 if unknown */
1194
1267
  } ConvertRowtypeExpr;
1195
1268
 
1196
1269
  /*----------
@@ -1205,7 +1278,7 @@ typedef struct CollateExpr
1205
1278
  Expr xpr;
1206
1279
  Expr *arg; /* input expression */
1207
1280
  Oid collOid; /* collation's OID */
1208
- int location; /* token location, or -1 if unknown */
1281
+ ParseLoc location; /* token location, or -1 if unknown */
1209
1282
  } CollateExpr;
1210
1283
 
1211
1284
  /*----------
@@ -1240,7 +1313,7 @@ typedef struct CaseExpr
1240
1313
  Expr *arg; /* implicit equality comparison argument */
1241
1314
  List *args; /* the arguments (list of WHEN clauses) */
1242
1315
  Expr *defresult; /* the default result (ELSE clause) */
1243
- int location; /* token location, or -1 if unknown */
1316
+ ParseLoc location; /* token location, or -1 if unknown */
1244
1317
  } CaseExpr;
1245
1318
 
1246
1319
  /*
@@ -1251,7 +1324,7 @@ typedef struct CaseWhen
1251
1324
  Expr xpr;
1252
1325
  Expr *expr; /* condition expression */
1253
1326
  Expr *result; /* substitution result */
1254
- int location; /* token location, or -1 if unknown */
1327
+ ParseLoc location; /* token location, or -1 if unknown */
1255
1328
  } CaseWhen;
1256
1329
 
1257
1330
  /*
@@ -1308,7 +1381,7 @@ typedef struct ArrayExpr
1308
1381
  /* true if elements are sub-arrays */
1309
1382
  bool multidims pg_node_attr(query_jumble_ignore);
1310
1383
  /* token location, or -1 if unknown */
1311
- int location;
1384
+ ParseLoc location;
1312
1385
  } ArrayExpr;
1313
1386
 
1314
1387
  /*
@@ -1359,7 +1432,7 @@ typedef struct RowExpr
1359
1432
  /* list of String, or NIL */
1360
1433
  List *colnames pg_node_attr(query_jumble_ignore);
1361
1434
 
1362
- int location; /* token location, or -1 if unknown */
1435
+ ParseLoc location; /* token location, or -1 if unknown */
1363
1436
  } RowExpr;
1364
1437
 
1365
1438
  /*
@@ -1384,7 +1457,7 @@ typedef enum RowCompareType
1384
1457
  ROWCOMPARE_EQ = 3, /* BTEqualStrategyNumber */
1385
1458
  ROWCOMPARE_GE = 4, /* BTGreaterEqualStrategyNumber */
1386
1459
  ROWCOMPARE_GT = 5, /* BTGreaterStrategyNumber */
1387
- ROWCOMPARE_NE = 6 /* no such btree strategy */
1460
+ ROWCOMPARE_NE = 6, /* no such btree strategy */
1388
1461
  } RowCompareType;
1389
1462
 
1390
1463
  typedef struct RowCompareExpr
@@ -1418,7 +1491,7 @@ typedef struct CoalesceExpr
1418
1491
  /* the arguments */
1419
1492
  List *args;
1420
1493
  /* token location, or -1 if unknown */
1421
- int location;
1494
+ ParseLoc location;
1422
1495
  } CoalesceExpr;
1423
1496
 
1424
1497
  /*
@@ -1444,7 +1517,7 @@ typedef struct MinMaxExpr
1444
1517
  /* the arguments */
1445
1518
  List *args;
1446
1519
  /* token location, or -1 if unknown */
1447
- int location;
1520
+ ParseLoc location;
1448
1521
  } MinMaxExpr;
1449
1522
 
1450
1523
  /*
@@ -1474,7 +1547,7 @@ typedef enum SQLValueFunctionOp
1474
1547
  SVFOP_USER,
1475
1548
  SVFOP_SESSION_USER,
1476
1549
  SVFOP_CURRENT_CATALOG,
1477
- SVFOP_CURRENT_SCHEMA
1550
+ SVFOP_CURRENT_SCHEMA,
1478
1551
  } SQLValueFunctionOp;
1479
1552
 
1480
1553
  typedef struct SQLValueFunction
@@ -1488,7 +1561,7 @@ typedef struct SQLValueFunction
1488
1561
  */
1489
1562
  Oid type pg_node_attr(query_jumble_ignore);
1490
1563
  int32 typmod;
1491
- int location; /* token location, or -1 if unknown */
1564
+ ParseLoc location; /* token location, or -1 if unknown */
1492
1565
  } SQLValueFunction;
1493
1566
 
1494
1567
  /*
@@ -1511,13 +1584,13 @@ typedef enum XmlExprOp
1511
1584
  IS_XMLPI, /* XMLPI(name [, args]) */
1512
1585
  IS_XMLROOT, /* XMLROOT(xml, version, standalone) */
1513
1586
  IS_XMLSERIALIZE, /* XMLSERIALIZE(is_document, xmlval, indent) */
1514
- IS_DOCUMENT /* xmlval IS DOCUMENT */
1587
+ IS_DOCUMENT, /* xmlval IS DOCUMENT */
1515
1588
  } XmlExprOp;
1516
1589
 
1517
1590
  typedef enum XmlOptionType
1518
1591
  {
1519
1592
  XMLOPTION_DOCUMENT,
1520
- XMLOPTION_CONTENT
1593
+ XMLOPTION_CONTENT,
1521
1594
  } XmlOptionType;
1522
1595
 
1523
1596
  typedef struct XmlExpr
@@ -1541,7 +1614,7 @@ typedef struct XmlExpr
1541
1614
  Oid type pg_node_attr(query_jumble_ignore);
1542
1615
  int32 typmod pg_node_attr(query_jumble_ignore);
1543
1616
  /* token location, or -1 if unknown */
1544
- int location;
1617
+ ParseLoc location;
1545
1618
  } XmlExpr;
1546
1619
 
1547
1620
  /*
@@ -1564,7 +1637,7 @@ typedef enum JsonFormatType
1564
1637
  {
1565
1638
  JS_FORMAT_DEFAULT, /* unspecified */
1566
1639
  JS_FORMAT_JSON, /* FORMAT JSON [ENCODING ...] */
1567
- JS_FORMAT_JSONB /* implicit internal format for RETURNING
1640
+ JS_FORMAT_JSONB, /* implicit internal format for RETURNING
1568
1641
  * jsonb */
1569
1642
  } JsonFormatType;
1570
1643
 
@@ -1577,7 +1650,7 @@ typedef struct JsonFormat
1577
1650
  NodeTag type;
1578
1651
  JsonFormatType format_type; /* format type */
1579
1652
  JsonEncoding encoding; /* JSON encoding */
1580
- int location; /* token location, or -1 if unknown */
1653
+ ParseLoc location; /* token location, or -1 if unknown */
1581
1654
  } JsonFormat;
1582
1655
 
1583
1656
  /*
@@ -1598,7 +1671,7 @@ typedef struct JsonReturning
1598
1671
  *
1599
1672
  * The actual value is obtained by evaluating formatted_expr. raw_expr is
1600
1673
  * only there for displaying the original user-written expression and is not
1601
- * evaluated by ExecInterpExpr() and eval_const_exprs_mutator().
1674
+ * evaluated by ExecInterpExpr() and eval_const_expressions_mutator().
1602
1675
  */
1603
1676
  typedef struct JsonValueExpr
1604
1677
  {
@@ -1613,7 +1686,10 @@ typedef enum JsonConstructorType
1613
1686
  JSCTOR_JSON_OBJECT = 1,
1614
1687
  JSCTOR_JSON_ARRAY = 2,
1615
1688
  JSCTOR_JSON_OBJECTAGG = 3,
1616
- JSCTOR_JSON_ARRAYAGG = 4
1689
+ JSCTOR_JSON_ARRAYAGG = 4,
1690
+ JSCTOR_JSON_PARSE = 5,
1691
+ JSCTOR_JSON_SCALAR = 6,
1692
+ JSCTOR_JSON_SERIALIZE = 7,
1617
1693
  } JsonConstructorType;
1618
1694
 
1619
1695
  /*
@@ -1630,7 +1706,7 @@ typedef struct JsonConstructorExpr
1630
1706
  JsonReturning *returning; /* RETURNING clause */
1631
1707
  bool absent_on_null; /* ABSENT ON NULL? */
1632
1708
  bool unique; /* WITH UNIQUE KEYS? (JSON_OBJECT[AGG] only) */
1633
- int location;
1709
+ ParseLoc location;
1634
1710
  } JsonConstructorExpr;
1635
1711
 
1636
1712
  /*
@@ -1642,7 +1718,7 @@ typedef enum JsonValueType
1642
1718
  JS_TYPE_ANY, /* IS JSON [VALUE] */
1643
1719
  JS_TYPE_OBJECT, /* IS JSON OBJECT */
1644
1720
  JS_TYPE_ARRAY, /* IS JSON ARRAY */
1645
- JS_TYPE_SCALAR /* IS JSON SCALAR */
1721
+ JS_TYPE_SCALAR, /* IS JSON SCALAR */
1646
1722
  } JsonValueType;
1647
1723
 
1648
1724
  /*
@@ -1656,9 +1732,198 @@ typedef struct JsonIsPredicate
1656
1732
  JsonFormat *format; /* FORMAT clause, if specified */
1657
1733
  JsonValueType item_type; /* JSON item type */
1658
1734
  bool unique_keys; /* check key uniqueness? */
1659
- int location; /* token location, or -1 if unknown */
1735
+ ParseLoc location; /* token location, or -1 if unknown */
1660
1736
  } JsonIsPredicate;
1661
1737
 
1738
+ /* Nodes used in SQL/JSON query functions */
1739
+
1740
+ /*
1741
+ * JsonWrapper -
1742
+ * representation of WRAPPER clause for JSON_QUERY()
1743
+ */
1744
+ typedef enum JsonWrapper
1745
+ {
1746
+ JSW_UNSPEC,
1747
+ JSW_NONE,
1748
+ JSW_CONDITIONAL,
1749
+ JSW_UNCONDITIONAL,
1750
+ } JsonWrapper;
1751
+
1752
+ /*
1753
+ * JsonBehaviorType -
1754
+ * enumeration of behavior types used in SQL/JSON ON ERROR/EMPTY clauses
1755
+ *
1756
+ * If enum members are reordered, get_json_behavior() from ruleutils.c
1757
+ * must be updated accordingly.
1758
+ */
1759
+ typedef enum JsonBehaviorType
1760
+ {
1761
+ JSON_BEHAVIOR_NULL = 0,
1762
+ JSON_BEHAVIOR_ERROR,
1763
+ JSON_BEHAVIOR_EMPTY,
1764
+ JSON_BEHAVIOR_TRUE,
1765
+ JSON_BEHAVIOR_FALSE,
1766
+ JSON_BEHAVIOR_UNKNOWN,
1767
+ JSON_BEHAVIOR_EMPTY_ARRAY,
1768
+ JSON_BEHAVIOR_EMPTY_OBJECT,
1769
+ JSON_BEHAVIOR_DEFAULT,
1770
+ } JsonBehaviorType;
1771
+
1772
+ /*
1773
+ * JsonBehavior
1774
+ * Specifications for ON ERROR / ON EMPTY behaviors of SQL/JSON
1775
+ * query functions specified by a JsonExpr
1776
+ *
1777
+ * 'expr' is the expression to emit when a given behavior (EMPTY or ERROR)
1778
+ * occurs on evaluating the SQL/JSON query function. 'coerce' is set to true
1779
+ * if 'expr' isn't already of the expected target type given by
1780
+ * JsonExpr.returning.
1781
+ */
1782
+ typedef struct JsonBehavior
1783
+ {
1784
+ NodeTag type;
1785
+
1786
+ JsonBehaviorType btype;
1787
+ Node *expr;
1788
+ bool coerce;
1789
+ ParseLoc location; /* token location, or -1 if unknown */
1790
+ } JsonBehavior;
1791
+
1792
+ /*
1793
+ * JsonExprOp -
1794
+ * enumeration of SQL/JSON query function types
1795
+ */
1796
+ typedef enum JsonExprOp
1797
+ {
1798
+ JSON_EXISTS_OP, /* JSON_EXISTS() */
1799
+ JSON_QUERY_OP, /* JSON_QUERY() */
1800
+ JSON_VALUE_OP, /* JSON_VALUE() */
1801
+ JSON_TABLE_OP, /* JSON_TABLE() */
1802
+ } JsonExprOp;
1803
+
1804
+ /*
1805
+ * JsonExpr -
1806
+ * Transformed representation of JSON_VALUE(), JSON_QUERY(), and
1807
+ * JSON_EXISTS()
1808
+ */
1809
+ typedef struct JsonExpr
1810
+ {
1811
+ Expr xpr;
1812
+
1813
+ JsonExprOp op;
1814
+
1815
+ char *column_name; /* JSON_TABLE() column name or NULL if this is
1816
+ * not for a JSON_TABLE() */
1817
+
1818
+ /* jsonb-valued expression to query */
1819
+ Node *formatted_expr;
1820
+
1821
+ /* Format of the above expression needed by ruleutils.c */
1822
+ JsonFormat *format;
1823
+
1824
+ /* jsonpath-valued expression containing the query pattern */
1825
+ Node *path_spec;
1826
+
1827
+ /* Expected type/format of the output. */
1828
+ JsonReturning *returning;
1829
+
1830
+ /* Information about the PASSING argument expressions */
1831
+ List *passing_names;
1832
+ List *passing_values;
1833
+
1834
+ /* User-specified or default ON EMPTY and ON ERROR behaviors */
1835
+ JsonBehavior *on_empty;
1836
+ JsonBehavior *on_error;
1837
+
1838
+ /*
1839
+ * Information about converting the result of jsonpath functions
1840
+ * JsonPathQuery() and JsonPathValue() to the RETURNING type.
1841
+ */
1842
+ bool use_io_coercion;
1843
+ bool use_json_coercion;
1844
+
1845
+ /* WRAPPER specification for JSON_QUERY */
1846
+ JsonWrapper wrapper;
1847
+
1848
+ /* KEEP or OMIT QUOTES for singleton scalars returned by JSON_QUERY() */
1849
+ bool omit_quotes;
1850
+
1851
+ /* JsonExpr's collation. */
1852
+ Oid collation;
1853
+
1854
+ /* Original JsonFuncExpr's location */
1855
+ ParseLoc location;
1856
+ } JsonExpr;
1857
+
1858
+ /*
1859
+ * JsonTablePath
1860
+ * A JSON path expression to be computed as part of evaluating
1861
+ * a JSON_TABLE plan node
1862
+ */
1863
+ typedef struct JsonTablePath
1864
+ {
1865
+ NodeTag type;
1866
+
1867
+ Const *value;
1868
+ char *name;
1869
+ } JsonTablePath;
1870
+
1871
+ /*
1872
+ * JsonTablePlan -
1873
+ * Abstract class to represent different types of JSON_TABLE "plans".
1874
+ * A plan is used to generate a "row pattern" value by evaluating a JSON
1875
+ * path expression against an input JSON document, which is then used for
1876
+ * populating JSON_TABLE() columns
1877
+ */
1878
+ typedef struct JsonTablePlan
1879
+ {
1880
+ pg_node_attr(abstract)
1881
+
1882
+ NodeTag type;
1883
+ } JsonTablePlan;
1884
+
1885
+ /*
1886
+ * JSON_TABLE plan to evaluate a JSON path expression and NESTED paths, if
1887
+ * any.
1888
+ */
1889
+ typedef struct JsonTablePathScan
1890
+ {
1891
+ JsonTablePlan plan;
1892
+
1893
+ /* JSON path to evaluate */
1894
+ JsonTablePath *path;
1895
+
1896
+ /*
1897
+ * ERROR/EMPTY ON ERROR behavior; only significant in the plan for the
1898
+ * top-level path.
1899
+ */
1900
+ bool errorOnError;
1901
+
1902
+ /* Plan(s) for nested columns, if any. */
1903
+ JsonTablePlan *child;
1904
+
1905
+ /*
1906
+ * 0-based index in TableFunc.colvalexprs of the 1st and the last column
1907
+ * covered by this plan. Both are -1 if all columns are nested and thus
1908
+ * computed by the child plan(s).
1909
+ */
1910
+ int colMin;
1911
+ int colMax;
1912
+ } JsonTablePathScan;
1913
+
1914
+ /*
1915
+ * JsonTableSiblingJoin -
1916
+ * Plan to join rows of sibling NESTED COLUMNS clauses in the same parent
1917
+ * COLUMNS clause
1918
+ */
1919
+ typedef struct JsonTableSiblingJoin
1920
+ {
1921
+ JsonTablePlan plan;
1922
+
1923
+ JsonTablePlan *lplan;
1924
+ JsonTablePlan *rplan;
1925
+ } JsonTableSiblingJoin;
1926
+
1662
1927
  /* ----------------
1663
1928
  * NullTest
1664
1929
  *
@@ -1690,7 +1955,7 @@ typedef struct NullTest
1690
1955
  NullTestType nulltesttype; /* IS NULL, IS NOT NULL */
1691
1956
  /* T to perform field-by-field null checks */
1692
1957
  bool argisrow pg_node_attr(query_jumble_ignore);
1693
- int location; /* token location, or -1 if unknown */
1958
+ ParseLoc location; /* token location, or -1 if unknown */
1694
1959
  } NullTest;
1695
1960
 
1696
1961
  /*
@@ -1712,9 +1977,38 @@ typedef struct BooleanTest
1712
1977
  Expr xpr;
1713
1978
  Expr *arg; /* input expression */
1714
1979
  BoolTestType booltesttype; /* test type */
1715
- int location; /* token location, or -1 if unknown */
1980
+ ParseLoc location; /* token location, or -1 if unknown */
1716
1981
  } BooleanTest;
1717
1982
 
1983
+
1984
+ /*
1985
+ * MergeAction
1986
+ *
1987
+ * Transformed representation of a WHEN clause in a MERGE statement
1988
+ */
1989
+
1990
+ typedef enum MergeMatchKind
1991
+ {
1992
+ MERGE_WHEN_MATCHED,
1993
+ MERGE_WHEN_NOT_MATCHED_BY_SOURCE,
1994
+ MERGE_WHEN_NOT_MATCHED_BY_TARGET
1995
+ } MergeMatchKind;
1996
+
1997
+ #define NUM_MERGE_MATCH_KINDS (MERGE_WHEN_NOT_MATCHED_BY_TARGET + 1)
1998
+
1999
+ typedef struct MergeAction
2000
+ {
2001
+ NodeTag type;
2002
+ MergeMatchKind matchKind; /* MATCHED/NOT MATCHED BY SOURCE/TARGET */
2003
+ CmdType commandType; /* INSERT/UPDATE/DELETE/DO NOTHING */
2004
+ /* OVERRIDING clause */
2005
+ OverridingKind override pg_node_attr(query_jumble_ignore);
2006
+ Node *qual; /* transformed WHEN conditions */
2007
+ List *targetList; /* the target list (of TargetEntry) */
2008
+ /* target attribute numbers of an UPDATE */
2009
+ List *updateColnos pg_node_attr(query_jumble_ignore);
2010
+ } MergeAction;
2011
+
1718
2012
  /*
1719
2013
  * CoerceToDomain
1720
2014
  *
@@ -1735,7 +2029,7 @@ typedef struct CoerceToDomain
1735
2029
  Oid resultcollid pg_node_attr(query_jumble_ignore);
1736
2030
  /* how to display this node */
1737
2031
  CoercionForm coercionformat pg_node_attr(query_jumble_ignore);
1738
- int location; /* token location, or -1 if unknown */
2032
+ ParseLoc location; /* token location, or -1 if unknown */
1739
2033
  } CoerceToDomain;
1740
2034
 
1741
2035
  /*
@@ -1757,7 +2051,7 @@ typedef struct CoerceToDomainValue
1757
2051
  /* collation for the substituted value */
1758
2052
  Oid collation pg_node_attr(query_jumble_ignore);
1759
2053
  /* token location, or -1 if unknown */
1760
- int location;
2054
+ ParseLoc location;
1761
2055
  } CoerceToDomainValue;
1762
2056
 
1763
2057
  /*
@@ -1777,7 +2071,7 @@ typedef struct SetToDefault
1777
2071
  /* collation for the substituted value */
1778
2072
  Oid collation pg_node_attr(query_jumble_ignore);
1779
2073
  /* token location, or -1 if unknown */
1780
- int location;
2074
+ ParseLoc location;
1781
2075
  } SetToDefault;
1782
2076
 
1783
2077
  /*