pg_query 2.2.1 → 4.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (466) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -1
  3. data/README.md +29 -33
  4. data/Rakefile +2 -2
  5. data/ext/pg_query/include/access/amapi.h +45 -1
  6. data/ext/pg_query/include/access/attmap.h +1 -1
  7. data/ext/pg_query/include/access/attnum.h +2 -2
  8. data/ext/pg_query/include/access/clog.h +4 -2
  9. data/ext/pg_query/include/access/commit_ts.h +6 -9
  10. data/ext/pg_query/include/access/detoast.h +1 -11
  11. data/ext/pg_query/include/access/genam.h +15 -12
  12. data/ext/pg_query/include/access/gin.h +2 -2
  13. data/ext/pg_query/include/access/htup.h +1 -1
  14. data/ext/pg_query/include/access/htup_details.h +75 -87
  15. data/ext/pg_query/include/access/itup.h +7 -1
  16. data/ext/pg_query/include/access/parallel.h +2 -2
  17. data/ext/pg_query/include/access/printtup.h +1 -1
  18. data/ext/pg_query/include/access/relation.h +1 -1
  19. data/ext/pg_query/include/access/relscan.h +17 -2
  20. data/ext/pg_query/include/access/rmgr.h +30 -3
  21. data/ext/pg_query/include/access/rmgrlist.h +23 -23
  22. data/ext/pg_query/include/access/sdir.h +1 -1
  23. data/ext/pg_query/include/access/skey.h +1 -1
  24. data/ext/pg_query/include/access/stratnum.h +4 -2
  25. data/ext/pg_query/include/access/sysattr.h +1 -1
  26. data/ext/pg_query/include/access/table.h +2 -1
  27. data/ext/pg_query/include/access/tableam.h +272 -20
  28. data/ext/pg_query/include/access/toast_compression.h +73 -0
  29. data/ext/pg_query/include/access/transam.h +123 -13
  30. data/ext/pg_query/include/access/tupconvert.h +1 -1
  31. data/ext/pg_query/include/access/tupdesc.h +1 -1
  32. data/ext/pg_query/include/access/tupmacs.h +3 -3
  33. data/ext/pg_query/include/access/twophase.h +3 -1
  34. data/ext/pg_query/include/access/xact.h +73 -19
  35. data/ext/pg_query/include/access/xlog.h +60 -155
  36. data/ext/pg_query/include/access/xlog_internal.h +40 -13
  37. data/ext/pg_query/include/access/xlogdefs.h +8 -16
  38. data/ext/pg_query/include/access/xlogprefetcher.h +55 -0
  39. data/ext/pg_query/include/access/xlogreader.h +145 -39
  40. data/ext/pg_query/include/access/xlogrecord.h +18 -9
  41. data/ext/pg_query/include/access/xlogrecovery.h +157 -0
  42. data/ext/pg_query/include/c.h +101 -44
  43. data/ext/pg_query/include/catalog/catalog.h +3 -1
  44. data/ext/pg_query/include/catalog/catversion.h +2 -2
  45. data/ext/pg_query/include/catalog/dependency.h +8 -16
  46. data/ext/pg_query/include/catalog/genbki.h +83 -5
  47. data/ext/pg_query/include/catalog/index.h +18 -3
  48. data/ext/pg_query/include/catalog/indexing.h +12 -324
  49. data/ext/pg_query/include/catalog/namespace.h +4 -2
  50. data/ext/pg_query/include/catalog/objectaccess.h +70 -2
  51. data/ext/pg_query/include/catalog/objectaddress.h +11 -6
  52. data/ext/pg_query/include/catalog/pg_aggregate.h +14 -10
  53. data/ext/pg_query/include/catalog/pg_aggregate_d.h +2 -1
  54. data/ext/pg_query/include/catalog/pg_am.h +4 -1
  55. data/ext/pg_query/include/catalog/pg_am_d.h +3 -1
  56. data/ext/pg_query/include/catalog/pg_attribute.h +27 -10
  57. data/ext/pg_query/include/catalog/pg_attribute_d.h +21 -18
  58. data/ext/pg_query/include/catalog/pg_authid.h +7 -2
  59. data/ext/pg_query/include/catalog/pg_authid_d.h +17 -9
  60. data/ext/pg_query/include/catalog/pg_class.h +44 -14
  61. data/ext/pg_query/include/catalog/pg_class_d.h +30 -1
  62. data/ext/pg_query/include/catalog/pg_collation.h +33 -8
  63. data/ext/pg_query/include/catalog/pg_collation_d.h +20 -3
  64. data/ext/pg_query/include/catalog/pg_constraint.h +38 -12
  65. data/ext/pg_query/include/catalog/pg_constraint_d.h +10 -4
  66. data/ext/pg_query/include/catalog/pg_control.h +3 -5
  67. data/ext/pg_query/include/catalog/pg_conversion.h +7 -4
  68. data/ext/pg_query/include/catalog/pg_conversion_d.h +4 -1
  69. data/ext/pg_query/include/catalog/pg_depend.h +11 -7
  70. data/ext/pg_query/include/catalog/pg_depend_d.h +3 -1
  71. data/ext/pg_query/include/catalog/pg_event_trigger.h +9 -3
  72. data/ext/pg_query/include/catalog/pg_event_trigger_d.h +3 -1
  73. data/ext/pg_query/include/catalog/pg_index.h +17 -7
  74. data/ext/pg_query/include/catalog/pg_index_d.h +20 -17
  75. data/ext/pg_query/include/catalog/pg_language.h +10 -5
  76. data/ext/pg_query/include/catalog/pg_language_d.h +3 -1
  77. data/ext/pg_query/include/catalog/pg_namespace.h +7 -2
  78. data/ext/pg_query/include/catalog/pg_namespace_d.h +3 -1
  79. data/ext/pg_query/include/catalog/pg_opclass.h +8 -5
  80. data/ext/pg_query/include/catalog/pg_opclass_d.h +3 -1
  81. data/ext/pg_query/include/catalog/pg_operator.h +18 -15
  82. data/ext/pg_query/include/catalog/pg_operator_d.h +37 -1
  83. data/ext/pg_query/include/catalog/pg_opfamily.h +6 -3
  84. data/ext/pg_query/include/catalog/pg_opfamily_d.h +3 -1
  85. data/ext/pg_query/include/catalog/pg_parameter_acl.h +60 -0
  86. data/ext/pg_query/include/catalog/pg_parameter_acl_d.h +34 -0
  87. data/ext/pg_query/include/catalog/pg_partitioned_table.h +20 -9
  88. data/ext/pg_query/include/catalog/pg_partitioned_table_d.h +2 -1
  89. data/ext/pg_query/include/catalog/pg_proc.h +20 -11
  90. data/ext/pg_query/include/catalog/pg_proc_d.h +10 -8
  91. data/ext/pg_query/include/catalog/pg_publication.h +50 -7
  92. data/ext/pg_query/include/catalog/pg_publication_d.h +3 -1
  93. data/ext/pg_query/include/catalog/pg_replication_origin.h +6 -1
  94. data/ext/pg_query/include/catalog/pg_replication_origin_d.h +5 -1
  95. data/ext/pg_query/include/catalog/pg_statistic.h +19 -12
  96. data/ext/pg_query/include/catalog/pg_statistic_d.h +2 -1
  97. data/ext/pg_query/include/catalog/pg_statistic_ext.h +19 -5
  98. data/ext/pg_query/include/catalog/pg_statistic_ext_d.h +7 -2
  99. data/ext/pg_query/include/catalog/pg_transform.h +8 -5
  100. data/ext/pg_query/include/catalog/pg_transform_d.h +3 -1
  101. data/ext/pg_query/include/catalog/pg_trigger.h +24 -8
  102. data/ext/pg_query/include/catalog/pg_trigger_d.h +4 -1
  103. data/ext/pg_query/include/catalog/pg_ts_config.h +6 -3
  104. data/ext/pg_query/include/catalog/pg_ts_config_d.h +3 -1
  105. data/ext/pg_query/include/catalog/pg_ts_dict.h +8 -3
  106. data/ext/pg_query/include/catalog/pg_ts_dict_d.h +3 -1
  107. data/ext/pg_query/include/catalog/pg_ts_parser.h +6 -3
  108. data/ext/pg_query/include/catalog/pg_ts_parser_d.h +3 -1
  109. data/ext/pg_query/include/catalog/pg_ts_template.h +6 -3
  110. data/ext/pg_query/include/catalog/pg_ts_template_d.h +3 -1
  111. data/ext/pg_query/include/catalog/pg_type.h +55 -24
  112. data/ext/pg_query/include/catalog/pg_type_d.h +70 -31
  113. data/ext/pg_query/include/catalog/storage.h +5 -3
  114. data/ext/pg_query/include/commands/async.h +3 -4
  115. data/ext/pg_query/include/commands/dbcommands.h +2 -1
  116. data/ext/pg_query/include/commands/defrem.h +11 -24
  117. data/ext/pg_query/include/commands/event_trigger.h +2 -2
  118. data/ext/pg_query/include/commands/explain.h +1 -1
  119. data/ext/pg_query/include/commands/prepare.h +1 -1
  120. data/ext/pg_query/include/commands/tablespace.h +2 -2
  121. data/ext/pg_query/include/commands/trigger.h +18 -16
  122. data/ext/pg_query/include/commands/user.h +2 -2
  123. data/ext/pg_query/include/commands/vacuum.h +88 -41
  124. data/ext/pg_query/include/commands/variable.h +1 -1
  125. data/ext/pg_query/include/common/file_perm.h +4 -4
  126. data/ext/pg_query/include/common/hashfn.h +1 -1
  127. data/ext/pg_query/include/common/ip.h +1 -7
  128. data/ext/pg_query/include/common/keywords.h +2 -6
  129. data/ext/pg_query/include/common/kwlookup.h +1 -1
  130. data/ext/pg_query/include/common/pg_prng.h +60 -0
  131. data/ext/pg_query/include/common/relpath.h +2 -2
  132. data/ext/pg_query/include/common/string.h +24 -1
  133. data/ext/pg_query/include/common/unicode_combining_table.h +114 -2
  134. data/ext/pg_query/include/common/unicode_east_asian_fw_table.h +125 -0
  135. data/ext/pg_query/include/datatype/timestamp.h +40 -1
  136. data/ext/pg_query/include/executor/execdesc.h +1 -1
  137. data/ext/pg_query/include/executor/executor.h +65 -22
  138. data/ext/pg_query/include/executor/functions.h +17 -3
  139. data/ext/pg_query/include/executor/instrument.h +33 -16
  140. data/ext/pg_query/include/executor/spi.h +41 -3
  141. data/ext/pg_query/include/executor/tablefunc.h +1 -1
  142. data/ext/pg_query/include/executor/tuptable.h +1 -1
  143. data/ext/pg_query/include/fmgr.h +13 -7
  144. data/ext/pg_query/include/funcapi.h +16 -4
  145. data/ext/pg_query/include/getaddrinfo.h +1 -1
  146. data/ext/pg_query/include/jit/jit.h +11 -11
  147. data/ext/pg_query/include/kwlist_d.h +517 -494
  148. data/ext/pg_query/include/lib/dshash.h +112 -0
  149. data/ext/pg_query/include/lib/ilist.h +20 -1
  150. data/ext/pg_query/include/lib/pairingheap.h +1 -1
  151. data/ext/pg_query/include/lib/simplehash.h +140 -15
  152. data/ext/pg_query/include/lib/sort_template.h +432 -0
  153. data/ext/pg_query/include/lib/stringinfo.h +1 -1
  154. data/ext/pg_query/include/libpq/auth.h +6 -4
  155. data/ext/pg_query/include/libpq/crypt.h +5 -4
  156. data/ext/pg_query/include/libpq/hba.h +43 -4
  157. data/ext/pg_query/include/libpq/libpq-be.h +23 -6
  158. data/ext/pg_query/include/libpq/libpq.h +30 -20
  159. data/ext/pg_query/include/libpq/pqcomm.h +17 -31
  160. data/ext/pg_query/include/libpq/pqformat.h +1 -1
  161. data/ext/pg_query/include/libpq/pqsignal.h +4 -4
  162. data/ext/pg_query/include/mb/pg_wchar.h +105 -23
  163. data/ext/pg_query/include/mb/stringinfo_mb.h +1 -1
  164. data/ext/pg_query/include/miscadmin.h +47 -41
  165. data/ext/pg_query/include/nodes/bitmapset.h +1 -1
  166. data/ext/pg_query/include/nodes/execnodes.h +270 -78
  167. data/ext/pg_query/include/nodes/extensible.h +4 -2
  168. data/ext/pg_query/include/nodes/lockoptions.h +1 -1
  169. data/ext/pg_query/include/nodes/makefuncs.h +7 -6
  170. data/ext/pg_query/include/nodes/memnodes.h +5 -3
  171. data/ext/pg_query/include/nodes/nodeFuncs.h +1 -1
  172. data/ext/pg_query/include/nodes/nodes.h +30 -11
  173. data/ext/pg_query/include/nodes/params.h +1 -1
  174. data/ext/pg_query/include/nodes/parsenodes.h +322 -90
  175. data/ext/pg_query/include/nodes/pathnodes.h +243 -66
  176. data/ext/pg_query/include/nodes/pg_list.h +75 -69
  177. data/ext/pg_query/include/nodes/plannodes.h +111 -28
  178. data/ext/pg_query/include/nodes/primnodes.h +99 -47
  179. data/ext/pg_query/include/nodes/print.h +1 -1
  180. data/ext/pg_query/include/nodes/tidbitmap.h +1 -1
  181. data/ext/pg_query/include/nodes/value.h +58 -39
  182. data/ext/pg_query/include/optimizer/cost.h +9 -2
  183. data/ext/pg_query/include/optimizer/geqo.h +9 -7
  184. data/ext/pg_query/include/optimizer/geqo_gene.h +1 -1
  185. data/ext/pg_query/include/optimizer/optimizer.h +25 -17
  186. data/ext/pg_query/include/optimizer/paths.h +6 -6
  187. data/ext/pg_query/include/optimizer/planmain.h +15 -14
  188. data/ext/pg_query/include/parser/analyze.h +19 -5
  189. data/ext/pg_query/include/parser/gram.h +947 -913
  190. data/ext/pg_query/include/parser/gramparse.h +1 -1
  191. data/ext/pg_query/include/parser/kwlist.h +463 -453
  192. data/ext/pg_query/include/parser/parse_agg.h +2 -7
  193. data/ext/pg_query/include/parser/parse_coerce.h +3 -1
  194. data/ext/pg_query/include/parser/parse_expr.h +2 -3
  195. data/ext/pg_query/include/parser/parse_func.h +2 -1
  196. data/ext/pg_query/include/parser/parse_node.h +21 -9
  197. data/ext/pg_query/include/parser/parse_oper.h +1 -3
  198. data/ext/pg_query/include/parser/parse_relation.h +5 -4
  199. data/ext/pg_query/include/parser/parse_type.h +1 -1
  200. data/ext/pg_query/include/parser/parser.h +31 -4
  201. data/ext/pg_query/include/parser/parsetree.h +1 -1
  202. data/ext/pg_query/include/parser/scanner.h +1 -1
  203. data/ext/pg_query/include/parser/scansup.h +2 -5
  204. data/ext/pg_query/include/partitioning/partdefs.h +1 -1
  205. data/ext/pg_query/include/pg_config.h +83 -41
  206. data/ext/pg_query/include/pg_config_manual.h +74 -21
  207. data/ext/pg_query/include/pg_getopt.h +6 -6
  208. data/ext/pg_query/include/pg_query.h +5 -4
  209. data/ext/pg_query/include/pg_query_enum_defs.c +358 -241
  210. data/ext/pg_query/include/pg_query_fingerprint_conds.c +44 -7
  211. data/ext/pg_query/include/pg_query_fingerprint_defs.c +939 -113
  212. data/ext/pg_query/include/pg_query_outfuncs_conds.c +43 -13
  213. data/ext/pg_query/include/pg_query_outfuncs_defs.c +151 -26
  214. data/ext/pg_query/include/pg_query_readfuncs_conds.c +11 -2
  215. data/ext/pg_query/include/pg_query_readfuncs_defs.c +173 -30
  216. data/ext/pg_query/include/pg_trace.h +1 -1
  217. data/ext/pg_query/include/pgstat.h +449 -1238
  218. data/ext/pg_query/include/pgtime.h +14 -4
  219. data/ext/pg_query/include/pl_gram.h +126 -128
  220. data/ext/pg_query/include/pl_reserved_kwlist.h +1 -1
  221. data/ext/pg_query/include/pl_reserved_kwlist_d.h +10 -10
  222. data/ext/pg_query/include/pl_unreserved_kwlist.h +2 -3
  223. data/ext/pg_query/include/pl_unreserved_kwlist_d.h +54 -56
  224. data/ext/pg_query/include/plerrcodes.h +9 -1
  225. data/ext/pg_query/include/plpgsql.h +52 -54
  226. data/ext/pg_query/include/port/atomics/arch-arm.h +7 -1
  227. data/ext/pg_query/include/port/atomics/arch-ppc.h +1 -1
  228. data/ext/pg_query/include/port/atomics/arch-x86.h +1 -1
  229. data/ext/pg_query/include/port/atomics/fallback.h +1 -1
  230. data/ext/pg_query/include/port/atomics/generic-gcc.h +3 -3
  231. data/ext/pg_query/include/port/atomics/generic.h +1 -1
  232. data/ext/pg_query/include/port/atomics.h +1 -1
  233. data/ext/pg_query/include/port/pg_bitutils.h +40 -10
  234. data/ext/pg_query/include/port/pg_bswap.h +1 -1
  235. data/ext/pg_query/include/port/pg_crc32c.h +1 -1
  236. data/ext/pg_query/include/port.h +71 -46
  237. data/ext/pg_query/include/portability/instr_time.h +1 -1
  238. data/ext/pg_query/include/postgres.h +60 -16
  239. data/ext/pg_query/include/postmaster/autovacuum.h +17 -17
  240. data/ext/pg_query/include/postmaster/auxprocess.h +20 -0
  241. data/ext/pg_query/include/postmaster/bgworker.h +2 -1
  242. data/ext/pg_query/include/postmaster/bgworker_internals.h +2 -2
  243. data/ext/pg_query/include/postmaster/bgwriter.h +5 -5
  244. data/ext/pg_query/include/postmaster/fork_process.h +1 -1
  245. data/ext/pg_query/include/postmaster/interrupt.h +1 -1
  246. data/ext/pg_query/include/postmaster/pgarch.h +42 -8
  247. data/ext/pg_query/include/postmaster/postmaster.h +18 -17
  248. data/ext/pg_query/include/postmaster/startup.h +39 -0
  249. data/ext/pg_query/include/postmaster/syslogger.h +15 -10
  250. data/ext/pg_query/include/postmaster/walwriter.h +3 -3
  251. data/ext/pg_query/include/protobuf/pg_query.pb-c.h +1419 -914
  252. data/ext/pg_query/include/protobuf/pg_query.pb.h +43678 -32769
  253. data/ext/pg_query/include/regex/regex.h +18 -16
  254. data/ext/pg_query/include/replication/logicallauncher.h +3 -5
  255. data/ext/pg_query/include/replication/logicalproto.h +161 -17
  256. data/ext/pg_query/include/replication/logicalworker.h +1 -1
  257. data/ext/pg_query/include/replication/origin.h +7 -7
  258. data/ext/pg_query/include/replication/reorderbuffer.h +259 -42
  259. data/ext/pg_query/include/replication/slot.h +22 -11
  260. data/ext/pg_query/include/replication/syncrep.h +5 -5
  261. data/ext/pg_query/include/replication/walreceiver.h +145 -13
  262. data/ext/pg_query/include/replication/walsender.h +8 -8
  263. data/ext/pg_query/include/rewrite/prs2lock.h +1 -1
  264. data/ext/pg_query/include/rewrite/rewriteHandler.h +1 -3
  265. data/ext/pg_query/include/rewrite/rewriteManip.h +1 -1
  266. data/ext/pg_query/include/rewrite/rewriteSupport.h +1 -1
  267. data/ext/pg_query/include/storage/backendid.h +3 -3
  268. data/ext/pg_query/include/storage/block.h +4 -10
  269. data/ext/pg_query/include/storage/buf.h +1 -1
  270. data/ext/pg_query/include/storage/bufmgr.h +19 -14
  271. data/ext/pg_query/include/storage/bufpage.h +6 -8
  272. data/ext/pg_query/include/storage/condition_variable.h +13 -2
  273. data/ext/pg_query/include/storage/dsm.h +4 -1
  274. data/ext/pg_query/include/storage/dsm_impl.h +3 -2
  275. data/ext/pg_query/include/storage/fd.h +33 -3
  276. data/ext/pg_query/include/storage/fileset.h +40 -0
  277. data/ext/pg_query/include/storage/ipc.h +4 -1
  278. data/ext/pg_query/include/storage/item.h +1 -1
  279. data/ext/pg_query/include/storage/itemid.h +1 -1
  280. data/ext/pg_query/include/storage/itemptr.h +3 -1
  281. data/ext/pg_query/include/storage/large_object.h +2 -2
  282. data/ext/pg_query/include/storage/latch.h +9 -13
  283. data/ext/pg_query/include/storage/lmgr.h +2 -1
  284. data/ext/pg_query/include/storage/lock.h +11 -8
  285. data/ext/pg_query/include/storage/lockdefs.h +2 -2
  286. data/ext/pg_query/include/storage/lwlock.h +5 -32
  287. data/ext/pg_query/include/storage/lwlocknames.h +0 -1
  288. data/ext/pg_query/include/storage/off.h +1 -1
  289. data/ext/pg_query/include/storage/pg_sema.h +1 -1
  290. data/ext/pg_query/include/storage/pg_shmem.h +9 -7
  291. data/ext/pg_query/include/storage/pmsignal.h +15 -4
  292. data/ext/pg_query/include/storage/predicate.h +4 -4
  293. data/ext/pg_query/include/storage/proc.h +173 -59
  294. data/ext/pg_query/include/storage/procarray.h +98 -0
  295. data/ext/pg_query/include/storage/proclist_types.h +1 -1
  296. data/ext/pg_query/include/storage/procsignal.h +3 -7
  297. data/ext/pg_query/include/storage/relfilenode.h +1 -1
  298. data/ext/pg_query/include/storage/s_lock.h +60 -21
  299. data/ext/pg_query/include/storage/sharedfileset.h +3 -11
  300. data/ext/pg_query/include/storage/shm_mq.h +5 -4
  301. data/ext/pg_query/include/storage/shm_toc.h +1 -1
  302. data/ext/pg_query/include/storage/shmem.h +1 -1
  303. data/ext/pg_query/include/storage/sinval.h +3 -3
  304. data/ext/pg_query/include/storage/sinvaladt.h +1 -1
  305. data/ext/pg_query/include/storage/smgr.h +10 -8
  306. data/ext/pg_query/include/storage/spin.h +2 -2
  307. data/ext/pg_query/include/storage/standby.h +13 -6
  308. data/ext/pg_query/include/storage/standbydefs.h +2 -2
  309. data/ext/pg_query/include/storage/sync.h +7 -3
  310. data/ext/pg_query/include/tcop/cmdtag.h +1 -1
  311. data/ext/pg_query/include/tcop/cmdtaglist.h +3 -2
  312. data/ext/pg_query/include/tcop/deparse_utility.h +1 -1
  313. data/ext/pg_query/include/tcop/dest.h +1 -1
  314. data/ext/pg_query/include/tcop/fastpath.h +1 -2
  315. data/ext/pg_query/include/tcop/pquery.h +1 -1
  316. data/ext/pg_query/include/tcop/tcopprot.h +19 -11
  317. data/ext/pg_query/include/tcop/utility.h +7 -3
  318. data/ext/pg_query/include/tsearch/ts_cache.h +2 -2
  319. data/ext/pg_query/include/utils/acl.h +24 -3
  320. data/ext/pg_query/include/utils/aclchk_internal.h +1 -1
  321. data/ext/pg_query/include/utils/array.h +7 -2
  322. data/ext/pg_query/include/utils/backend_progress.h +44 -0
  323. data/ext/pg_query/include/utils/backend_status.h +321 -0
  324. data/ext/pg_query/include/utils/builtins.h +10 -11
  325. data/ext/pg_query/include/utils/bytea.h +3 -2
  326. data/ext/pg_query/include/utils/catcache.h +1 -1
  327. data/ext/pg_query/include/utils/date.h +1 -1
  328. data/ext/pg_query/include/utils/datetime.h +8 -7
  329. data/ext/pg_query/include/utils/datum.h +9 -1
  330. data/ext/pg_query/include/utils/dsa.h +1 -1
  331. data/ext/pg_query/include/utils/dynahash.h +4 -3
  332. data/ext/pg_query/include/utils/elog.h +52 -21
  333. data/ext/pg_query/include/utils/errcodes.h +2 -0
  334. data/ext/pg_query/include/utils/expandeddatum.h +1 -1
  335. data/ext/pg_query/include/utils/expandedrecord.h +1 -1
  336. data/ext/pg_query/include/utils/float.h +7 -7
  337. data/ext/pg_query/include/utils/fmgroids.h +1300 -696
  338. data/ext/pg_query/include/utils/fmgrprotos.h +199 -16
  339. data/ext/pg_query/include/utils/fmgrtab.h +6 -5
  340. data/ext/pg_query/include/utils/guc.h +69 -43
  341. data/ext/pg_query/include/utils/guc_tables.h +23 -19
  342. data/ext/pg_query/include/utils/hsearch.h +15 -11
  343. data/ext/pg_query/include/utils/inval.h +4 -1
  344. data/ext/pg_query/include/utils/lsyscache.h +11 -1
  345. data/ext/pg_query/include/utils/memdebug.h +1 -1
  346. data/ext/pg_query/include/utils/memutils.h +8 -3
  347. data/ext/pg_query/include/utils/numeric.h +19 -5
  348. data/ext/pg_query/include/utils/palloc.h +25 -3
  349. data/ext/pg_query/include/utils/partcache.h +1 -1
  350. data/ext/pg_query/include/utils/pg_locale.h +17 -9
  351. data/ext/pg_query/include/utils/pg_lsn.h +1 -1
  352. data/ext/pg_query/include/utils/pgstat_internal.h +784 -0
  353. data/ext/pg_query/include/utils/pidfile.h +1 -1
  354. data/ext/pg_query/include/utils/plancache.h +6 -5
  355. data/ext/pg_query/include/utils/portal.h +10 -12
  356. data/ext/pg_query/include/utils/ps_status.h +1 -1
  357. data/ext/pg_query/include/utils/queryenvironment.h +1 -1
  358. data/ext/pg_query/include/utils/queryjumble.h +88 -0
  359. data/ext/pg_query/include/utils/regproc.h +14 -3
  360. data/ext/pg_query/include/utils/rel.h +71 -19
  361. data/ext/pg_query/include/utils/relcache.h +8 -5
  362. data/ext/pg_query/include/utils/reltrigger.h +1 -1
  363. data/ext/pg_query/include/utils/resowner.h +1 -1
  364. data/ext/pg_query/include/utils/rls.h +2 -2
  365. data/ext/pg_query/include/utils/ruleutils.h +4 -1
  366. data/ext/pg_query/include/utils/sharedtuplestore.h +1 -1
  367. data/ext/pg_query/include/utils/snapmgr.h +34 -14
  368. data/ext/pg_query/include/utils/snapshot.h +14 -1
  369. data/ext/pg_query/include/utils/sortsupport.h +117 -2
  370. data/ext/pg_query/include/utils/syscache.h +6 -1
  371. data/ext/pg_query/include/utils/timeout.h +11 -4
  372. data/ext/pg_query/include/utils/timestamp.h +6 -5
  373. data/ext/pg_query/include/utils/tuplesort.h +25 -11
  374. data/ext/pg_query/include/utils/tuplestore.h +2 -2
  375. data/ext/pg_query/include/utils/typcache.h +24 -17
  376. data/ext/pg_query/include/utils/tzparser.h +1 -1
  377. data/ext/pg_query/include/utils/varlena.h +5 -3
  378. data/ext/pg_query/include/utils/wait_event.h +289 -0
  379. data/ext/pg_query/include/utils/xml.h +4 -4
  380. data/ext/pg_query/pg_query.pb-c.c +4302 -2304
  381. data/ext/pg_query/pg_query_deparse.c +1106 -373
  382. data/ext/pg_query/pg_query_fingerprint.c +30 -10
  383. data/ext/pg_query/pg_query_json_plpgsql.c +0 -25
  384. data/ext/pg_query/pg_query_normalize.c +1 -1
  385. data/ext/pg_query/pg_query_outfuncs_json.c +54 -16
  386. data/ext/pg_query/pg_query_outfuncs_protobuf.c +70 -10
  387. data/ext/pg_query/pg_query_parse.c +1 -1
  388. data/ext/pg_query/pg_query_readfuncs_protobuf.c +42 -8
  389. data/ext/pg_query/pg_query_scan.c +2 -1
  390. data/ext/pg_query/pg_query_split.c +3 -2
  391. data/ext/pg_query/src_backend_catalog_namespace.c +20 -9
  392. data/ext/pg_query/src_backend_catalog_pg_proc.c +4 -1
  393. data/ext/pg_query/src_backend_commands_define.c +11 -1
  394. data/ext/pg_query/src_backend_nodes_bitmapset.c +3 -1
  395. data/ext/pg_query/src_backend_nodes_copyfuncs.c +401 -76
  396. data/ext/pg_query/src_backend_nodes_equalfuncs.c +290 -46
  397. data/ext/pg_query/src_backend_nodes_extensible.c +1 -1
  398. data/ext/pg_query/src_backend_nodes_list.c +74 -11
  399. data/ext/pg_query/src_backend_nodes_makefuncs.c +5 -4
  400. data/ext/pg_query/src_backend_nodes_nodeFuncs.c +55 -12
  401. data/ext/pg_query/src_backend_nodes_value.c +28 -19
  402. data/ext/pg_query/src_backend_parser_gram.c +33874 -31261
  403. data/ext/pg_query/src_backend_parser_parser.c +26 -7
  404. data/ext/pg_query/src_backend_parser_scan.c +172 -209
  405. data/ext/pg_query/src_backend_parser_scansup.c +4 -28
  406. data/ext/pg_query/src_backend_postmaster_postmaster.c +77 -106
  407. data/ext/pg_query/src_backend_storage_ipc_ipc.c +13 -4
  408. data/ext/pg_query/src_backend_storage_lmgr_s_lock.c +5 -4
  409. data/ext/pg_query/src_backend_tcop_postgres.c +62 -23
  410. data/ext/pg_query/src_backend_utils_activity_pgstat_database.c +140 -0
  411. data/ext/pg_query/src_backend_utils_adt_datum.c +13 -1
  412. data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +1 -1
  413. data/ext/pg_query/src_backend_utils_adt_format_type.c +6 -2
  414. data/ext/pg_query/src_backend_utils_adt_ruleutils.c +71 -5
  415. data/ext/pg_query/src_backend_utils_error_assert.c +16 -14
  416. data/ext/pg_query/src_backend_utils_error_elog.c +172 -99
  417. data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +12 -17
  418. data/ext/pg_query/src_backend_utils_hash_dynahash.c +40 -10
  419. data/ext/pg_query/src_backend_utils_init_globals.c +5 -5
  420. data/ext/pg_query/src_backend_utils_mb_mbutils.c +55 -66
  421. data/ext/pg_query/src_backend_utils_misc_guc.c +206 -45
  422. data/ext/pg_query/src_backend_utils_mmgr_aset.c +7 -5
  423. data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +123 -35
  424. data/ext/pg_query/src_common_encnames.c +1 -1
  425. data/ext/pg_query/src_common_hashfn.c +3 -3
  426. data/ext/pg_query/src_common_keywords.c +15 -2
  427. data/ext/pg_query/src_common_kwlist_d.h +517 -494
  428. data/ext/pg_query/src_common_kwlookup.c +1 -1
  429. data/ext/pg_query/src_common_pg_prng.c +152 -0
  430. data/ext/pg_query/src_common_psprintf.c +1 -1
  431. data/ext/pg_query/src_common_string.c +7 -1
  432. data/ext/pg_query/src_common_stringinfo.c +1 -1
  433. data/ext/pg_query/src_common_wchar.c +701 -109
  434. data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +45 -20
  435. data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +1 -18
  436. data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +1233 -1259
  437. data/ext/pg_query/src_pl_plpgsql_src_pl_handler.c +1 -1
  438. data/ext/pg_query/src_pl_plpgsql_src_pl_reserved_kwlist_d.h +10 -10
  439. data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +2 -2
  440. data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +54 -56
  441. data/ext/pg_query/src_port_pg_bitutils.c +41 -31
  442. data/ext/pg_query/src_port_pgsleep.c +1 -1
  443. data/ext/pg_query/src_port_pgstrcasecmp.c +1 -1
  444. data/ext/pg_query/src_port_qsort.c +12 -224
  445. data/ext/pg_query/src_port_snprintf.c +37 -13
  446. data/ext/pg_query/src_port_strerror.c +9 -19
  447. data/ext/pg_query/src_port_strnlen.c +1 -1
  448. data/lib/pg_query/filter_columns.rb +1 -1
  449. data/lib/pg_query/fingerprint.rb +5 -1
  450. data/lib/pg_query/node.rb +2 -2
  451. data/lib/pg_query/param_refs.rb +1 -1
  452. data/lib/pg_query/parse.rb +18 -8
  453. data/lib/pg_query/pg_query_pb.rb +1108 -942
  454. data/lib/pg_query/truncate.rb +1 -1
  455. data/lib/pg_query/version.rb +1 -1
  456. metadata +28 -18
  457. data/ext/pg_query/include/access/xloginsert.h +0 -64
  458. data/ext/pg_query/include/bootstrap/bootstrap.h +0 -62
  459. data/ext/pg_query/include/parser/parse_clause.h +0 -54
  460. data/ext/pg_query/include/parser/parse_collate.h +0 -27
  461. data/ext/pg_query/include/parser/parse_target.h +0 -46
  462. data/ext/pg_query/pg_query_ruby_freebsd.sym +0 -2
  463. data/ext/pg_query/src_backend_libpq_pqcomm.c +0 -659
  464. data/ext/pg_query/src_backend_parser_parse_expr.c +0 -313
  465. data/ext/pg_query/src_port_erand48.c +0 -127
  466. data/ext/pg_query/src_port_random.c +0 -31
@@ -12,7 +12,7 @@
12
12
  * identifying statement boundaries in multi-statement source strings.
13
13
  *
14
14
  *
15
- * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
15
+ * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
16
16
  * Portions Copyright (c) 1994, Regents of the University of California
17
17
  *
18
18
  * src/include/nodes/parsenodes.h
@@ -62,6 +62,14 @@ typedef enum SortByNulls
62
62
  SORTBY_NULLS_LAST
63
63
  } SortByNulls;
64
64
 
65
+ /* Options for [ ALL | DISTINCT ] */
66
+ typedef enum SetQuantifier
67
+ {
68
+ SET_QUANTIFIER_DEFAULT,
69
+ SET_QUANTIFIER_ALL,
70
+ SET_QUANTIFIER_DISTINCT
71
+ } SetQuantifier;
72
+
65
73
  /*
66
74
  * Grantable rights are encoded so that we can OR them together in a bitmask.
67
75
  * The present representation of AclItem limits us to 16 distinct rights,
@@ -84,7 +92,9 @@ typedef uint32 AclMode; /* a bitmask of privilege bits */
84
92
  #define ACL_CREATE (1<<9) /* for namespaces and databases */
85
93
  #define ACL_CREATE_TEMP (1<<10) /* for databases */
86
94
  #define ACL_CONNECT (1<<11) /* for databases */
87
- #define N_ACL_RIGHTS 12 /* 1 plus the last 1<<x */
95
+ #define ACL_SET (1<<12) /* for configuration parameters */
96
+ #define ACL_ALTER_SYSTEM (1<<13) /* for configuration parameters */
97
+ #define N_ACL_RIGHTS 14 /* 1 plus the last 1<<x */
88
98
  #define ACL_NO_RIGHTS 0
89
99
  /* Currently, SELECT ... FOR [KEY] UPDATE/SHARE requires UPDATE privileges */
90
100
  #define ACL_SELECT_FOR_UPDATE ACL_UPDATE
@@ -109,7 +119,7 @@ typedef struct Query
109
119
  {
110
120
  NodeTag type;
111
121
 
112
- CmdType commandType; /* select|insert|update|delete|utility */
122
+ CmdType commandType; /* select|insert|update|delete|merge|utility */
113
123
 
114
124
  QuerySource querySource; /* where did I come from? */
115
125
 
@@ -120,7 +130,7 @@ typedef struct Query
120
130
  Node *utilityStmt; /* non-null if commandType == CMD_UTILITY */
121
131
 
122
132
  int resultRelation; /* rtable index of target relation for
123
- * INSERT/UPDATE/DELETE; 0 for SELECT */
133
+ * INSERT/UPDATE/DELETE/MERGE; 0 for SELECT */
124
134
 
125
135
  bool hasAggs; /* has aggregates in tlist or havingQual */
126
136
  bool hasWindowFuncs; /* has window functions in tlist */
@@ -132,10 +142,16 @@ typedef struct Query
132
142
  bool hasForUpdate; /* FOR [KEY] UPDATE/SHARE was specified */
133
143
  bool hasRowSecurity; /* rewriter has applied some RLS policy */
134
144
 
145
+ bool isReturn; /* is a RETURN statement */
146
+
135
147
  List *cteList; /* WITH list (of CommonTableExpr's) */
136
148
 
137
149
  List *rtable; /* list of range table entries */
138
- FromExpr *jointree; /* table join tree (FROM and WHERE clauses) */
150
+ FromExpr *jointree; /* table join tree (FROM and WHERE clauses);
151
+ * also USING clause for MERGE */
152
+
153
+ List *mergeActionList; /* list of actions for MERGE (only) */
154
+ bool mergeUseOuterJoin; /* whether to use outer join */
139
155
 
140
156
  List *targetList; /* target list (of TargetEntry) */
141
157
 
@@ -146,6 +162,7 @@ typedef struct Query
146
162
  List *returningList; /* return-values list (of TargetEntry) */
147
163
 
148
164
  List *groupClause; /* a list of SortGroupClause's */
165
+ bool groupDistinct; /* is the group by clause distinct? */
149
166
 
150
167
  List *groupingSets; /* a list of GroupingSet's if present */
151
168
 
@@ -207,7 +224,7 @@ typedef struct Query
207
224
  typedef struct TypeName
208
225
  {
209
226
  NodeTag type;
210
- List *names; /* qualified name (list of Value strings) */
227
+ List *names; /* qualified name (list of String nodes) */
211
228
  Oid typeOid; /* type identified by OID */
212
229
  bool setof; /* is a set? */
213
230
  bool pct_type; /* %TYPE specified? */
@@ -220,7 +237,7 @@ typedef struct TypeName
220
237
  /*
221
238
  * ColumnRef - specifies a reference to a column, or possibly a whole tuple
222
239
  *
223
- * The "fields" list must be nonempty. It can contain string Value nodes
240
+ * The "fields" list must be nonempty. It can contain String nodes
224
241
  * (representing names) and A_Star nodes (representing occurrence of a '*').
225
242
  * Currently, A_Star must appear only as the last list element --- the grammar
226
243
  * is responsible for enforcing this!
@@ -233,7 +250,7 @@ typedef struct TypeName
233
250
  typedef struct ColumnRef
234
251
  {
235
252
  NodeTag type;
236
- List *fields; /* field names (Value strings) or A_Star */
253
+ List *fields; /* field names (String nodes) or A_Star */
237
254
  int location; /* token location, or -1 if unknown */
238
255
  } ColumnRef;
239
256
 
@@ -258,7 +275,6 @@ typedef enum A_Expr_Kind
258
275
  AEXPR_DISTINCT, /* IS DISTINCT FROM - name must be "=" */
259
276
  AEXPR_NOT_DISTINCT, /* IS NOT DISTINCT FROM - name must be "=" */
260
277
  AEXPR_NULLIF, /* NULLIF - name must be "=" */
261
- AEXPR_OF, /* IS [NOT] OF - name must be "=" or "<>" */
262
278
  AEXPR_IN, /* [NOT] IN - name must be "=" or "<>" */
263
279
  AEXPR_LIKE, /* [NOT] LIKE - name must be "~~" or "!~~" */
264
280
  AEXPR_ILIKE, /* [NOT] ILIKE - name must be "~~*" or "!~~*" */
@@ -266,8 +282,7 @@ typedef enum A_Expr_Kind
266
282
  AEXPR_BETWEEN, /* name must be "BETWEEN" */
267
283
  AEXPR_NOT_BETWEEN, /* name must be "NOT BETWEEN" */
268
284
  AEXPR_BETWEEN_SYM, /* name must be "BETWEEN SYMMETRIC" */
269
- AEXPR_NOT_BETWEEN_SYM, /* name must be "NOT BETWEEN SYMMETRIC" */
270
- AEXPR_PAREN /* nameless dummy node for parentheses */
285
+ AEXPR_NOT_BETWEEN_SYM /* name must be "NOT BETWEEN SYMMETRIC" */
271
286
  } A_Expr_Kind;
272
287
 
273
288
  typedef struct A_Expr
@@ -286,7 +301,21 @@ typedef struct A_Expr
286
301
  typedef struct A_Const
287
302
  {
288
303
  NodeTag type;
289
- Value val; /* value (includes type info, see value.h) */
304
+
305
+ /*
306
+ * Value nodes are inline for performance. You can treat 'val' as a node,
307
+ * as in IsA(&val, Integer). 'val' is not valid if isnull is true.
308
+ */
309
+ union ValUnion
310
+ {
311
+ Node node;
312
+ Integer ival;
313
+ Float fval;
314
+ Boolean boolval;
315
+ String sval;
316
+ BitString bsval;
317
+ } val;
318
+ bool isnull; /* SQL NULL constant */
290
319
  int location; /* token location, or -1 if unknown */
291
320
  } A_Const;
292
321
 
@@ -318,6 +347,7 @@ typedef struct CollateClause
318
347
  typedef enum RoleSpecType
319
348
  {
320
349
  ROLESPEC_CSTRING, /* role name is stored as a C string */
350
+ ROLESPEC_CURRENT_ROLE, /* role spec is CURRENT_ROLE */
321
351
  ROLESPEC_CURRENT_USER, /* role spec is CURRENT_USER */
322
352
  ROLESPEC_SESSION_USER, /* role spec is SESSION_USER */
323
353
  ROLESPEC_PUBLIC /* role name is "public" */
@@ -352,11 +382,12 @@ typedef struct FuncCall
352
382
  List *args; /* the arguments (list of exprs) */
353
383
  List *agg_order; /* ORDER BY (list of SortBy) */
354
384
  Node *agg_filter; /* FILTER clause, if any */
385
+ struct WindowDef *over; /* OVER clause, if any */
355
386
  bool agg_within_group; /* ORDER BY appeared in WITHIN GROUP */
356
387
  bool agg_star; /* argument was really '*' */
357
388
  bool agg_distinct; /* arguments were labeled DISTINCT */
358
389
  bool func_variadic; /* last argument was labeled VARIADIC */
359
- struct WindowDef *over; /* OVER clause, if any */
390
+ CoercionForm funcformat; /* how to display this node */
360
391
  int location; /* token location, or -1 if unknown */
361
392
  } FuncCall;
362
393
 
@@ -389,7 +420,7 @@ typedef struct A_Indices
389
420
  * A_Indirection - select a field and/or array element from an expression
390
421
  *
391
422
  * The indirection list can contain A_Indices nodes (representing
392
- * subscripting), string Value nodes (representing field selection --- the
423
+ * subscripting), String nodes (representing field selection --- the
393
424
  * string value is the name of the field to select), and A_Star nodes
394
425
  * (representing selection of all fields of a composite type).
395
426
  * For example, a complex selection operation like
@@ -646,6 +677,7 @@ typedef struct ColumnDef
646
677
  NodeTag type;
647
678
  char *colname; /* name of column */
648
679
  TypeName *typeName; /* type of column */
680
+ char *compression; /* compression method for column */
649
681
  int inhcount; /* number of times column is inherited */
650
682
  bool is_local; /* column has local (non-inherited) def'n */
651
683
  bool is_not_null; /* NOT NULL constraint specified? */
@@ -678,13 +710,14 @@ typedef struct TableLikeClause
678
710
  typedef enum TableLikeOption
679
711
  {
680
712
  CREATE_TABLE_LIKE_COMMENTS = 1 << 0,
681
- CREATE_TABLE_LIKE_CONSTRAINTS = 1 << 1,
682
- CREATE_TABLE_LIKE_DEFAULTS = 1 << 2,
683
- CREATE_TABLE_LIKE_GENERATED = 1 << 3,
684
- CREATE_TABLE_LIKE_IDENTITY = 1 << 4,
685
- CREATE_TABLE_LIKE_INDEXES = 1 << 5,
686
- CREATE_TABLE_LIKE_STATISTICS = 1 << 6,
687
- CREATE_TABLE_LIKE_STORAGE = 1 << 7,
713
+ CREATE_TABLE_LIKE_COMPRESSION = 1 << 1,
714
+ CREATE_TABLE_LIKE_CONSTRAINTS = 1 << 2,
715
+ CREATE_TABLE_LIKE_DEFAULTS = 1 << 3,
716
+ CREATE_TABLE_LIKE_GENERATED = 1 << 4,
717
+ CREATE_TABLE_LIKE_IDENTITY = 1 << 5,
718
+ CREATE_TABLE_LIKE_INDEXES = 1 << 6,
719
+ CREATE_TABLE_LIKE_STATISTICS = 1 << 7,
720
+ CREATE_TABLE_LIKE_STORAGE = 1 << 8,
688
721
  CREATE_TABLE_LIKE_ALL = PG_INT32_MAX
689
722
  } TableLikeOption;
690
723
 
@@ -731,7 +764,8 @@ typedef struct DefElem
731
764
  NodeTag type;
732
765
  char *defnamespace; /* NULL if unqualified name */
733
766
  char *defname;
734
- Node *arg; /* a (Value *) or a (TypeName *) */
767
+ Node *arg; /* typically Integer, Float, String, or
768
+ * TypeName */
735
769
  DefElemAction defaction; /* unspecified action, or SET/ADD/DROP */
736
770
  int location; /* token location, or -1 if unknown */
737
771
  } DefElem;
@@ -860,6 +894,7 @@ typedef struct PartitionCmd
860
894
  NodeTag type;
861
895
  RangeVar *name; /* name of partition to attach/detach */
862
896
  PartitionBoundSpec *bound; /* FOR VALUES, if attaching */
897
+ bool concurrent;
863
898
  } PartitionCmd;
864
899
 
865
900
  /****************************************************************************
@@ -996,8 +1031,8 @@ typedef struct RangeTblEntry
996
1031
  *
997
1032
  * rellockmode is really LOCKMODE, but it's declared int to avoid having
998
1033
  * to include lock-related headers here. It must be RowExclusiveLock if
999
- * the RTE is an INSERT/UPDATE/DELETE target, else RowShareLock if the RTE
1000
- * is a SELECT FOR UPDATE/FOR SHARE target, else AccessShareLock.
1034
+ * the RTE is an INSERT/UPDATE/DELETE/MERGE target, else RowShareLock if
1035
+ * the RTE is a SELECT FOR UPDATE/FOR SHARE target, else AccessShareLock.
1001
1036
  *
1002
1037
  * Note: in some cases, rule expansion may result in RTEs that are marked
1003
1038
  * with RowExclusiveLock even though they are not the target of the
@@ -1057,6 +1092,13 @@ typedef struct RangeTblEntry
1057
1092
  List *joinleftcols; /* left-side input column numbers */
1058
1093
  List *joinrightcols; /* right-side input column numbers */
1059
1094
 
1095
+ /*
1096
+ * join_using_alias is an alias clause attached directly to JOIN/USING. It
1097
+ * is different from the alias field (below) in that it does not hide the
1098
+ * range variables of the tables being joined.
1099
+ */
1100
+ Alias *join_using_alias;
1101
+
1060
1102
  /*
1061
1103
  * Fields valid for a function RTE (else NIL/zero):
1062
1104
  *
@@ -1111,7 +1153,7 @@ typedef struct RangeTblEntry
1111
1153
  * Fields valid for ENR RTEs (else NULL/zero):
1112
1154
  */
1113
1155
  char *enrname; /* name of ephemeral named relation */
1114
- double enrtuples; /* estimated or actual from caller */
1156
+ Cardinality enrtuples; /* estimated or actual from caller */
1115
1157
 
1116
1158
  /*
1117
1159
  * Fields valid in all RTEs:
@@ -1185,7 +1227,9 @@ typedef enum WCOKind
1185
1227
  WCO_VIEW_CHECK, /* WCO on an auto-updatable view */
1186
1228
  WCO_RLS_INSERT_CHECK, /* RLS INSERT WITH CHECK policy */
1187
1229
  WCO_RLS_UPDATE_CHECK, /* RLS UPDATE WITH CHECK policy */
1188
- WCO_RLS_CONFLICT_CHECK /* RLS ON CONFLICT DO UPDATE USING policy */
1230
+ WCO_RLS_CONFLICT_CHECK, /* RLS ON CONFLICT DO UPDATE USING policy */
1231
+ WCO_RLS_MERGE_UPDATE_CHECK, /* RLS MERGE UPDATE USING policy */
1232
+ WCO_RLS_MERGE_DELETE_CHECK /* RLS MERGE DELETE USING policy */
1189
1233
  } WCOKind;
1190
1234
 
1191
1235
  typedef struct WithCheckOption
@@ -1316,7 +1360,7 @@ typedef struct SortGroupClause
1316
1360
  *
1317
1361
  * SETS( SIMPLE(1,2), CUBE( SIMPLE(3), SIMPLE(4,5) ) )
1318
1362
  */
1319
- typedef enum
1363
+ typedef enum GroupingSetKind
1320
1364
  {
1321
1365
  GROUPING_SET_EMPTY,
1322
1366
  GROUPING_SET_SIMPLE,
@@ -1360,6 +1404,7 @@ typedef struct WindowClause
1360
1404
  int frameOptions; /* frame_clause options, see WindowDef */
1361
1405
  Node *startOffset; /* expression for starting bound, if any */
1362
1406
  Node *endOffset; /* expression for ending bound, if any */
1407
+ List *runCondition; /* qual to help short-circuit execution */
1363
1408
  Oid startInRangeFunc; /* in_range function for startOffset */
1364
1409
  Oid endInRangeFunc; /* in_range function for endOffset */
1365
1410
  Oid inRangeColl; /* collation for in_range tests */
@@ -1439,9 +1484,8 @@ typedef struct OnConflictClause
1439
1484
  /*
1440
1485
  * CommonTableExpr -
1441
1486
  * representation of WITH list element
1442
- *
1443
- * We don't currently support the SEARCH or CYCLE clause.
1444
1487
  */
1488
+
1445
1489
  typedef enum CTEMaterialize
1446
1490
  {
1447
1491
  CTEMaterializeDefault, /* no option specified */
@@ -1449,6 +1493,31 @@ typedef enum CTEMaterialize
1449
1493
  CTEMaterializeNever /* NOT MATERIALIZED */
1450
1494
  } CTEMaterialize;
1451
1495
 
1496
+ typedef struct CTESearchClause
1497
+ {
1498
+ NodeTag type;
1499
+ List *search_col_list;
1500
+ bool search_breadth_first;
1501
+ char *search_seq_column;
1502
+ int location;
1503
+ } CTESearchClause;
1504
+
1505
+ typedef struct CTECycleClause
1506
+ {
1507
+ NodeTag type;
1508
+ List *cycle_col_list;
1509
+ char *cycle_mark_column;
1510
+ Node *cycle_mark_value;
1511
+ Node *cycle_mark_default;
1512
+ char *cycle_path_column;
1513
+ int location;
1514
+ /* These fields are set during parse analysis: */
1515
+ Oid cycle_mark_type; /* common type of _value and _default */
1516
+ int cycle_mark_typmod;
1517
+ Oid cycle_mark_collation;
1518
+ Oid cycle_mark_neop; /* <> operator for type */
1519
+ } CTECycleClause;
1520
+
1452
1521
  typedef struct CommonTableExpr
1453
1522
  {
1454
1523
  NodeTag type;
@@ -1457,6 +1526,8 @@ typedef struct CommonTableExpr
1457
1526
  CTEMaterialize ctematerialized; /* is this an optimization fence? */
1458
1527
  /* SelectStmt/InsertStmt/etc before parse analysis, Query afterwards: */
1459
1528
  Node *ctequery; /* the CTE's subquery */
1529
+ CTESearchClause *search_clause;
1530
+ CTECycleClause *cycle_clause;
1460
1531
  int location; /* token location, or -1 if unknown */
1461
1532
  /* These fields are set during parse analysis: */
1462
1533
  bool cterecursive; /* is this CTE actually recursive? */
@@ -1475,6 +1546,39 @@ typedef struct CommonTableExpr
1475
1546
  ((Query *) (cte)->ctequery)->targetList : \
1476
1547
  ((Query *) (cte)->ctequery)->returningList)
1477
1548
 
1549
+ /*
1550
+ * MergeWhenClause -
1551
+ * raw parser representation of a WHEN clause in a MERGE statement
1552
+ *
1553
+ * This is transformed into MergeAction by parse analysis
1554
+ */
1555
+ typedef struct MergeWhenClause
1556
+ {
1557
+ NodeTag type;
1558
+ bool matched; /* true=MATCHED, false=NOT MATCHED */
1559
+ CmdType commandType; /* INSERT/UPDATE/DELETE/DO NOTHING */
1560
+ OverridingKind override; /* OVERRIDING clause */
1561
+ Node *condition; /* WHEN conditions (raw parser) */
1562
+ List *targetList; /* INSERT/UPDATE targetlist */
1563
+ /* the following members are only used in INSERT actions */
1564
+ List *values; /* VALUES to INSERT, or NULL */
1565
+ } MergeWhenClause;
1566
+
1567
+ /*
1568
+ * MergeAction -
1569
+ * Transformed representation of a WHEN clause in a MERGE statement
1570
+ */
1571
+ typedef struct MergeAction
1572
+ {
1573
+ NodeTag type;
1574
+ bool matched; /* true=MATCHED, false=NOT MATCHED */
1575
+ CmdType commandType; /* INSERT/UPDATE/DELETE/DO NOTHING */
1576
+ OverridingKind override; /* OVERRIDING clause */
1577
+ Node *qual; /* transformed WHEN conditions */
1578
+ List *targetList; /* the target list (of TargetEntry) */
1579
+ List *updateColnos; /* target attribute numbers of an UPDATE */
1580
+ } MergeAction;
1581
+
1478
1582
  /*
1479
1583
  * TriggerTransition -
1480
1584
  * representation of transition row or table naming clause
@@ -1568,6 +1672,20 @@ typedef struct UpdateStmt
1568
1672
  WithClause *withClause; /* WITH clause */
1569
1673
  } UpdateStmt;
1570
1674
 
1675
+ /* ----------------------
1676
+ * Merge Statement
1677
+ * ----------------------
1678
+ */
1679
+ typedef struct MergeStmt
1680
+ {
1681
+ NodeTag type;
1682
+ RangeVar *relation; /* target relation to merge into */
1683
+ Node *sourceRelation; /* source relation */
1684
+ Node *joinCondition; /* join condition between source and target */
1685
+ List *mergeWhenClauses; /* list of MergeWhenClause(es) */
1686
+ WithClause *withClause; /* WITH clause */
1687
+ } MergeStmt;
1688
+
1571
1689
  /* ----------------------
1572
1690
  * Select Statement
1573
1691
  *
@@ -1603,6 +1721,7 @@ typedef struct SelectStmt
1603
1721
  List *fromClause; /* the FROM clause */
1604
1722
  Node *whereClause; /* WHERE qualification */
1605
1723
  List *groupClause; /* GROUP BY clauses */
1724
+ bool groupDistinct; /* Is this GROUP BY DISTINCT? */
1606
1725
  Node *havingClause; /* HAVING conditional-expression */
1607
1726
  List *windowClause; /* WINDOW window_name AS (...), ... */
1608
1727
 
@@ -1675,6 +1794,35 @@ typedef struct SetOperationStmt
1675
1794
  } SetOperationStmt;
1676
1795
 
1677
1796
 
1797
+ /*
1798
+ * RETURN statement (inside SQL function body)
1799
+ */
1800
+ typedef struct ReturnStmt
1801
+ {
1802
+ NodeTag type;
1803
+ Node *returnval;
1804
+ } ReturnStmt;
1805
+
1806
+
1807
+ /* ----------------------
1808
+ * PL/pgSQL Assignment Statement
1809
+ *
1810
+ * Like SelectStmt, this is transformed into a SELECT Query.
1811
+ * However, the targetlist of the result looks more like an UPDATE.
1812
+ * ----------------------
1813
+ */
1814
+ typedef struct PLAssignStmt
1815
+ {
1816
+ NodeTag type;
1817
+
1818
+ char *name; /* initial column name */
1819
+ List *indirection; /* subscripts and field names, if any */
1820
+ int nnames; /* number of names to use in ColumnRef */
1821
+ SelectStmt *val; /* the PL/pgSQL expression to assign */
1822
+ int location; /* name's token location, or -1 if unknown */
1823
+ } PLAssignStmt;
1824
+
1825
+
1678
1826
  /*****************************************************************************
1679
1827
  * Other Statements (no optimizations required)
1680
1828
  *
@@ -1724,9 +1872,11 @@ typedef enum ObjectType
1724
1872
  OBJECT_OPCLASS,
1725
1873
  OBJECT_OPERATOR,
1726
1874
  OBJECT_OPFAMILY,
1875
+ OBJECT_PARAMETER_ACL,
1727
1876
  OBJECT_POLICY,
1728
1877
  OBJECT_PROCEDURE,
1729
1878
  OBJECT_PUBLICATION,
1879
+ OBJECT_PUBLICATION_NAMESPACE,
1730
1880
  OBJECT_PUBLICATION_REL,
1731
1881
  OBJECT_ROLE,
1732
1882
  OBJECT_ROUTINE,
@@ -1781,7 +1931,7 @@ typedef struct AlterTableStmt
1781
1931
  NodeTag type;
1782
1932
  RangeVar *relation; /* table to work on */
1783
1933
  List *cmds; /* list of subcommands */
1784
- ObjectType relkind; /* type of object */
1934
+ ObjectType objtype; /* type of object */
1785
1935
  bool missing_ok; /* skip error if table missing */
1786
1936
  } AlterTableStmt;
1787
1937
 
@@ -1800,6 +1950,7 @@ typedef enum AlterTableType
1800
1950
  AT_SetOptions, /* alter column set ( options ) */
1801
1951
  AT_ResetOptions, /* alter column reset ( options ) */
1802
1952
  AT_SetStorage, /* alter column set storage */
1953
+ AT_SetCompression, /* alter column set compression */
1803
1954
  AT_DropColumn, /* drop column */
1804
1955
  AT_DropColumnRecurse, /* internal to commands/tablecmds.c */
1805
1956
  AT_AddIndex, /* add index */
@@ -1823,6 +1974,7 @@ typedef enum AlterTableType
1823
1974
  AT_SetLogged, /* SET LOGGED */
1824
1975
  AT_SetUnLogged, /* SET UNLOGGED */
1825
1976
  AT_DropOids, /* SET WITHOUT OIDS */
1977
+ AT_SetAccessMethod, /* SET ACCESS METHOD */
1826
1978
  AT_SetTableSpace, /* SET TABLESPACE */
1827
1979
  AT_SetRelOptions, /* SET (...) -- AM specific parameters */
1828
1980
  AT_ResetRelOptions, /* RESET (...) -- AM specific parameters */
@@ -1851,9 +2003,11 @@ typedef enum AlterTableType
1851
2003
  AT_GenericOptions, /* OPTIONS (...) */
1852
2004
  AT_AttachPartition, /* ATTACH PARTITION */
1853
2005
  AT_DetachPartition, /* DETACH PARTITION */
2006
+ AT_DetachPartitionFinalize, /* DETACH PARTITION FINALIZE */
1854
2007
  AT_AddIdentity, /* ADD IDENTITY */
1855
2008
  AT_SetIdentity, /* SET identity column options */
1856
- AT_DropIdentity /* DROP IDENTITY */
2009
+ AT_DropIdentity, /* DROP IDENTITY */
2010
+ AT_ReAddStatistics /* internal to commands/tablecmds.c */
1857
2011
  } AlterTableType;
1858
2012
 
1859
2013
  typedef struct ReplicaIdentityStmt
@@ -1935,27 +2089,39 @@ typedef struct GrantStmt
1935
2089
  GrantTargetType targtype; /* type of the grant target */
1936
2090
  ObjectType objtype; /* kind of object being operated on */
1937
2091
  List *objects; /* list of RangeVar nodes, ObjectWithArgs
1938
- * nodes, or plain names (as Value strings) */
2092
+ * nodes, or plain names (as String values) */
1939
2093
  List *privileges; /* list of AccessPriv nodes */
1940
2094
  /* privileges == NIL denotes ALL PRIVILEGES */
1941
2095
  List *grantees; /* list of RoleSpec nodes */
1942
2096
  bool grant_option; /* grant or revoke grant option */
2097
+ RoleSpec *grantor;
1943
2098
  DropBehavior behavior; /* drop behavior (for REVOKE) */
1944
2099
  } GrantStmt;
1945
2100
 
1946
2101
  /*
1947
- * Note: ObjectWithArgs carries only the types of the input parameters of the
1948
- * function. So it is sufficient to identify an existing function, but it
1949
- * is not enough info to define a function nor to call it.
2102
+ * ObjectWithArgs represents a function/procedure/operator name plus parameter
2103
+ * identification.
2104
+ *
2105
+ * objargs includes only the types of the input parameters of the object.
2106
+ * In some contexts, that will be all we have, and it's enough to look up
2107
+ * objects according to the traditional Postgres rules (i.e., when only input
2108
+ * arguments matter).
2109
+ *
2110
+ * objfuncargs, if not NIL, carries the full specification of the parameter
2111
+ * list, including parameter mode annotations.
2112
+ *
2113
+ * Some grammar productions can set args_unspecified = true instead of
2114
+ * providing parameter info. In this case, lookup will succeed only if
2115
+ * the object name is unique. Note that otherwise, NIL parameter lists
2116
+ * mean zero arguments.
1950
2117
  */
1951
2118
  typedef struct ObjectWithArgs
1952
2119
  {
1953
2120
  NodeTag type;
1954
2121
  List *objname; /* qualified name of function/operator */
1955
- List *objargs; /* list of Typename nodes */
1956
- bool args_unspecified; /* argument list was omitted, so name must
1957
- * be unique (note that objargs == NIL
1958
- * means zero args) */
2122
+ List *objargs; /* list of Typename nodes (input args only) */
2123
+ List *objfuncargs; /* list of FunctionParameter nodes */
2124
+ bool args_unspecified; /* argument list was omitted? */
1959
2125
  } ObjectWithArgs;
1960
2126
 
1961
2127
  /*
@@ -1969,7 +2135,7 @@ typedef struct AccessPriv
1969
2135
  {
1970
2136
  NodeTag type;
1971
2137
  char *priv_name; /* string name of privilege */
1972
- List *cols; /* list of Value strings */
2138
+ List *cols; /* list of String */
1973
2139
  } AccessPriv;
1974
2140
 
1975
2141
  /* ----------------------
@@ -1978,7 +2144,7 @@ typedef struct AccessPriv
1978
2144
  * Note: because of the parsing ambiguity with the GRANT <privileges>
1979
2145
  * statement, granted_roles is a list of AccessPriv; the execution code
1980
2146
  * should complain if any column lists appear. grantee_roles is a list
1981
- * of role names, as Value strings.
2147
+ * of role names, as String values.
1982
2148
  * ----------------------
1983
2149
  */
1984
2150
  typedef struct GrantRoleStmt
@@ -2033,7 +2199,7 @@ typedef struct CopyStmt
2033
2199
  * preserve the distinction in VariableSetKind for CreateCommandTag().
2034
2200
  * ----------------------
2035
2201
  */
2036
- typedef enum
2202
+ typedef enum VariableSetKind
2037
2203
  {
2038
2204
  VAR_SET_VALUE, /* SET var = value */
2039
2205
  VAR_SET_DEFAULT, /* SET var TO DEFAULT */
@@ -2079,7 +2245,7 @@ typedef struct CreateStmt
2079
2245
  RangeVar *relation; /* relation to create */
2080
2246
  List *tableElts; /* column definitions (list of ColumnDef) */
2081
2247
  List *inhRelations; /* relations to inherit from (list of
2082
- * inhRelation) */
2248
+ * RangeVar) */
2083
2249
  PartitionBoundSpec *partbound; /* FOR VALUES clause */
2084
2250
  PartitionSpec *partspec; /* PARTITION BY clause */
2085
2251
  TypeName *ofTypename; /* OF typename */
@@ -2171,6 +2337,7 @@ typedef struct Constraint
2171
2337
  char generated_when; /* ALWAYS or BY DEFAULT */
2172
2338
 
2173
2339
  /* Fields used for unique constraints (UNIQUE and PRIMARY KEY): */
2340
+ bool nulls_not_distinct; /* null treatment for UNIQUE constraints */
2174
2341
  List *keys; /* String nodes naming referenced key
2175
2342
  * column(s) */
2176
2343
  List *including; /* String nodes naming referenced nonkey
@@ -2196,6 +2363,7 @@ typedef struct Constraint
2196
2363
  char fk_matchtype; /* FULL, PARTIAL, SIMPLE */
2197
2364
  char fk_upd_action; /* ON UPDATE action */
2198
2365
  char fk_del_action; /* ON DELETE action */
2366
+ List *fk_del_set_cols; /* ON DELETE SET NULL/DEFAULT (col1, col2) */
2199
2367
  List *old_conpfeqop; /* pg_constraint.conpfeqop of my former self */
2200
2368
  Oid old_pktable_oid; /* pg_constraint.confrelid of my former
2201
2369
  * self */
@@ -2434,10 +2602,12 @@ typedef struct CreateAmStmt
2434
2602
  typedef struct CreateTrigStmt
2435
2603
  {
2436
2604
  NodeTag type;
2605
+ bool replace; /* replace trigger if already exists */
2606
+ bool isconstraint; /* This is a constraint trigger */
2437
2607
  char *trigname; /* TRIGGER's name */
2438
2608
  RangeVar *relation; /* relation trigger is on */
2439
2609
  List *funcname; /* qual. name of function to call */
2440
- List *args; /* list of (T_String) Values or NIL */
2610
+ List *args; /* list of String or NIL */
2441
2611
  bool row; /* ROW/STATEMENT */
2442
2612
  /* timing uses the TRIGGER_TYPE bits defined in catalog/pg_trigger.h */
2443
2613
  int16 timing; /* BEFORE, AFTER, or INSTEAD */
@@ -2445,7 +2615,6 @@ typedef struct CreateTrigStmt
2445
2615
  int16 events; /* "OR" of INSERT/UPDATE/DELETE/TRUNCATE */
2446
2616
  List *columns; /* column names, or NIL for all columns */
2447
2617
  Node *whenClause; /* qual expression, or NULL if none */
2448
- bool isconstraint; /* This is a constraint trigger */
2449
2618
  /* explicitly named transition data */
2450
2619
  List *transitionRels; /* TriggerTransition nodes, or NIL if none */
2451
2620
  /* The remaining fields are only used for constraint triggers */
@@ -2574,7 +2743,7 @@ typedef struct DefineStmt
2574
2743
  NodeTag type;
2575
2744
  ObjectType kind; /* aggregate, operator, type */
2576
2745
  bool oldstyle; /* hack to signal old CREATE AGG syntax */
2577
- List *defnames; /* qualified name (list of Value strings) */
2746
+ List *defnames; /* qualified name (list of String) */
2578
2747
  List *args; /* a list of TypeName (if needed) */
2579
2748
  List *definition; /* a list of DefElem */
2580
2749
  bool if_not_exists; /* just do nothing if it already exists? */
@@ -2588,7 +2757,7 @@ typedef struct DefineStmt
2588
2757
  typedef struct CreateDomainStmt
2589
2758
  {
2590
2759
  NodeTag type;
2591
- List *domainname; /* qualified name (list of Value strings) */
2760
+ List *domainname; /* qualified name (list of String) */
2592
2761
  TypeName *typeName; /* the base type */
2593
2762
  CollateClause *collClause; /* untransformed COLLATE spec, if any */
2594
2763
  List *constraints; /* constraints (list of Constraint nodes) */
@@ -2601,7 +2770,7 @@ typedef struct CreateDomainStmt
2601
2770
  typedef struct CreateOpClassStmt
2602
2771
  {
2603
2772
  NodeTag type;
2604
- List *opclassname; /* qualified name (list of Value strings) */
2773
+ List *opclassname; /* qualified name (list of String) */
2605
2774
  List *opfamilyname; /* qualified name (ditto); NIL if omitted */
2606
2775
  char *amname; /* name of index AM opclass is for */
2607
2776
  TypeName *datatype; /* datatype of indexed column */
@@ -2633,7 +2802,7 @@ typedef struct CreateOpClassItem
2633
2802
  typedef struct CreateOpFamilyStmt
2634
2803
  {
2635
2804
  NodeTag type;
2636
- List *opfamilyname; /* qualified name (list of Value strings) */
2805
+ List *opfamilyname; /* qualified name (list of String) */
2637
2806
  char *amname; /* name of index AM opfamily is for */
2638
2807
  } CreateOpFamilyStmt;
2639
2808
 
@@ -2644,7 +2813,7 @@ typedef struct CreateOpFamilyStmt
2644
2813
  typedef struct AlterOpFamilyStmt
2645
2814
  {
2646
2815
  NodeTag type;
2647
- List *opfamilyname; /* qualified name (list of Value strings) */
2816
+ List *opfamilyname; /* qualified name (list of String) */
2648
2817
  char *amname; /* name of index AM opfamily is for */
2649
2818
  bool isDrop; /* ADD or DROP the items? */
2650
2819
  List *items; /* List of CreateOpClassItem nodes */
@@ -2714,12 +2883,13 @@ typedef struct SecLabelStmt
2714
2883
  #define CURSOR_OPT_SCROLL 0x0002 /* SCROLL explicitly given */
2715
2884
  #define CURSOR_OPT_NO_SCROLL 0x0004 /* NO SCROLL explicitly given */
2716
2885
  #define CURSOR_OPT_INSENSITIVE 0x0008 /* INSENSITIVE */
2717
- #define CURSOR_OPT_HOLD 0x0010 /* WITH HOLD */
2886
+ #define CURSOR_OPT_ASENSITIVE 0x0010 /* ASENSITIVE */
2887
+ #define CURSOR_OPT_HOLD 0x0020 /* WITH HOLD */
2718
2888
  /* these planner-control flags do not correspond to any SQL grammar: */
2719
- #define CURSOR_OPT_FAST_PLAN 0x0020 /* prefer fast-start plan */
2720
- #define CURSOR_OPT_GENERIC_PLAN 0x0040 /* force use of generic plan */
2721
- #define CURSOR_OPT_CUSTOM_PLAN 0x0080 /* force use of custom plan */
2722
- #define CURSOR_OPT_PARALLEL_OK 0x0100 /* parallel mode OK */
2889
+ #define CURSOR_OPT_FAST_PLAN 0x0100 /* prefer fast-start plan */
2890
+ #define CURSOR_OPT_GENERIC_PLAN 0x0200 /* force use of generic plan */
2891
+ #define CURSOR_OPT_CUSTOM_PLAN 0x0400 /* force use of custom plan */
2892
+ #define CURSOR_OPT_PARALLEL_OK 0x0800 /* parallel mode OK */
2723
2893
 
2724
2894
  typedef struct DeclareCursorStmt
2725
2895
  {
@@ -2796,6 +2966,7 @@ typedef struct IndexStmt
2796
2966
  SubTransactionId oldFirstRelfilenodeSubid; /* rd_firstRelfilenodeSubid of
2797
2967
  * oldNode */
2798
2968
  bool unique; /* is index unique? */
2969
+ bool nulls_not_distinct; /* null treatment for UNIQUE constraints */
2799
2970
  bool primary; /* is index a primary key? */
2800
2971
  bool isconstraint; /* is it for a pkey/unique constraint? */
2801
2972
  bool deferrable; /* is the constraint DEFERRABLE? */
@@ -2814,14 +2985,30 @@ typedef struct IndexStmt
2814
2985
  typedef struct CreateStatsStmt
2815
2986
  {
2816
2987
  NodeTag type;
2817
- List *defnames; /* qualified name (list of Value strings) */
2818
- List *stat_types; /* stat types (list of Value strings) */
2988
+ List *defnames; /* qualified name (list of String) */
2989
+ List *stat_types; /* stat types (list of String) */
2819
2990
  List *exprs; /* expressions to build statistics on */
2820
2991
  List *relations; /* rels to build stats on (list of RangeVar) */
2821
2992
  char *stxcomment; /* comment to apply to stats, or NULL */
2993
+ bool transformed; /* true when transformStatsStmt is finished */
2822
2994
  bool if_not_exists; /* do nothing if stats name already exists */
2823
2995
  } CreateStatsStmt;
2824
2996
 
2997
+ /*
2998
+ * StatsElem - statistics parameters (used in CREATE STATISTICS)
2999
+ *
3000
+ * For a plain attribute, 'name' is the name of the referenced table column
3001
+ * and 'expr' is NULL. For an expression, 'name' is NULL and 'expr' is the
3002
+ * expression tree.
3003
+ */
3004
+ typedef struct StatsElem
3005
+ {
3006
+ NodeTag type;
3007
+ char *name; /* name of attribute to index, or NULL */
3008
+ Node *expr; /* expression to index, or NULL */
3009
+ } StatsElem;
3010
+
3011
+
2825
3012
  /* ----------------------
2826
3013
  * Alter Statistics Statement
2827
3014
  * ----------------------
@@ -2829,7 +3016,7 @@ typedef struct CreateStatsStmt
2829
3016
  typedef struct AlterStatsStmt
2830
3017
  {
2831
3018
  NodeTag type;
2832
- List *defnames; /* qualified name (list of Value strings) */
3019
+ List *defnames; /* qualified name (list of String) */
2833
3020
  int stxstattarget; /* statistics target */
2834
3021
  bool missing_ok; /* skip error if statistics object is missing */
2835
3022
  } AlterStatsStmt;
@@ -2847,6 +3034,7 @@ typedef struct CreateFunctionStmt
2847
3034
  List *parameters; /* a list of FunctionParameter */
2848
3035
  TypeName *returnType; /* the return type */
2849
3036
  List *options; /* a list of DefElem */
3037
+ Node *sql_body;
2850
3038
  } CreateFunctionStmt;
2851
3039
 
2852
3040
  typedef enum FunctionParameterMode
@@ -2856,7 +3044,9 @@ typedef enum FunctionParameterMode
2856
3044
  FUNC_PARAM_OUT = 'o', /* output only */
2857
3045
  FUNC_PARAM_INOUT = 'b', /* both */
2858
3046
  FUNC_PARAM_VARIADIC = 'v', /* variadic (always input) */
2859
- FUNC_PARAM_TABLE = 't' /* table function output column */
3047
+ FUNC_PARAM_TABLE = 't', /* table function output column */
3048
+ /* this is not used in pg_proc: */
3049
+ FUNC_PARAM_DEFAULT = 'd' /* default; effectively same as IN */
2860
3050
  } FunctionParameterMode;
2861
3051
 
2862
3052
  typedef struct FunctionParameter
@@ -2899,13 +3089,19 @@ typedef struct InlineCodeBlock
2899
3089
 
2900
3090
  /* ----------------------
2901
3091
  * CALL statement
3092
+ *
3093
+ * OUT-mode arguments are removed from the transformed funcexpr. The outargs
3094
+ * list contains copies of the expressions for all output arguments, in the
3095
+ * order of the procedure's declared arguments. (outargs is never evaluated,
3096
+ * but is useful to the caller as a reference for what to assign to.)
2902
3097
  * ----------------------
2903
3098
  */
2904
3099
  typedef struct CallStmt
2905
3100
  {
2906
3101
  NodeTag type;
2907
3102
  FuncCall *funccall; /* from the parser */
2908
- FuncExpr *funcexpr; /* transformed */
3103
+ FuncExpr *funcexpr; /* transformed call, with only input args */
3104
+ List *outargs; /* transformed output-argument expressions */
2909
3105
  } CallStmt;
2910
3106
 
2911
3107
  typedef struct CallContext
@@ -2942,7 +3138,7 @@ typedef struct AlterObjectDependsStmt
2942
3138
  ObjectType objectType; /* OBJECT_FUNCTION, OBJECT_TRIGGER, etc */
2943
3139
  RangeVar *relation; /* in case a table is involved */
2944
3140
  Node *object; /* name of the object */
2945
- Value *extname; /* extension name */
3141
+ String *extname; /* extension name */
2946
3142
  bool remove; /* set true to remove dep rather than add */
2947
3143
  } AlterObjectDependsStmt;
2948
3144
 
@@ -3088,8 +3284,8 @@ typedef struct CompositeTypeStmt
3088
3284
  typedef struct CreateEnumStmt
3089
3285
  {
3090
3286
  NodeTag type;
3091
- List *typeName; /* qualified name (list of Value strings) */
3092
- List *vals; /* enum values (list of Value strings) */
3287
+ List *typeName; /* qualified name (list of String) */
3288
+ List *vals; /* enum values (list of String) */
3093
3289
  } CreateEnumStmt;
3094
3290
 
3095
3291
  /* ----------------------
@@ -3099,7 +3295,7 @@ typedef struct CreateEnumStmt
3099
3295
  typedef struct CreateRangeStmt
3100
3296
  {
3101
3297
  NodeTag type;
3102
- List *typeName; /* qualified name (list of Value strings) */
3298
+ List *typeName; /* qualified name (list of String) */
3103
3299
  List *params; /* range parameters (list of DefElem) */
3104
3300
  } CreateRangeStmt;
3105
3301
 
@@ -3110,7 +3306,7 @@ typedef struct CreateRangeStmt
3110
3306
  typedef struct AlterEnumStmt
3111
3307
  {
3112
3308
  NodeTag type;
3113
- List *typeName; /* qualified name (list of Value strings) */
3309
+ List *typeName; /* qualified name (list of String) */
3114
3310
  char *oldVal; /* old enum value's name, if renaming */
3115
3311
  char *newVal; /* new enum value's name */
3116
3312
  char *newValNeighbor; /* neighboring enum value, if specified */
@@ -3172,6 +3368,12 @@ typedef struct AlterDatabaseStmt
3172
3368
  List *options; /* List of DefElem nodes */
3173
3369
  } AlterDatabaseStmt;
3174
3370
 
3371
+ typedef struct AlterDatabaseRefreshCollStmt
3372
+ {
3373
+ NodeTag type;
3374
+ char *dbname;
3375
+ } AlterDatabaseRefreshCollStmt;
3376
+
3175
3377
  typedef struct AlterDatabaseSetStmt
3176
3378
  {
3177
3379
  NodeTag type;
@@ -3205,18 +3407,12 @@ typedef struct AlterSystemStmt
3205
3407
  * Cluster Statement (support pbrown's cluster index implementation)
3206
3408
  * ----------------------
3207
3409
  */
3208
- typedef enum ClusterOption
3209
- {
3210
- CLUOPT_RECHECK = 1 << 0, /* recheck relation state */
3211
- CLUOPT_VERBOSE = 1 << 1 /* print progress info */
3212
- } ClusterOption;
3213
-
3214
3410
  typedef struct ClusterStmt
3215
3411
  {
3216
3412
  NodeTag type;
3217
3413
  RangeVar *relation; /* relation being indexed, or NULL if all */
3218
3414
  char *indexname; /* original index defined */
3219
- int options; /* OR of ClusterOption flags */
3415
+ List *params; /* list of DefElem nodes */
3220
3416
  } ClusterStmt;
3221
3417
 
3222
3418
  /* ----------------------
@@ -3282,7 +3478,7 @@ typedef struct CreateTableAsStmt
3282
3478
  NodeTag type;
3283
3479
  Node *query; /* the query (see comments above) */
3284
3480
  IntoClause *into; /* destination table */
3285
- ObjectType relkind; /* OBJECT_TABLE or OBJECT_MATVIEW */
3481
+ ObjectType objtype; /* OBJECT_TABLE or OBJECT_MATVIEW */
3286
3482
  bool is_select_into; /* it was written as SELECT INTO */
3287
3483
  bool if_not_exists; /* just do nothing if it already exists? */
3288
3484
  } CreateTableAsStmt;
@@ -3354,11 +3550,6 @@ typedef struct ConstraintsSetStmt
3354
3550
  * REINDEX Statement
3355
3551
  * ----------------------
3356
3552
  */
3357
-
3358
- /* Reindex options */
3359
- #define REINDEXOPT_VERBOSE (1 << 0) /* print progress info */
3360
- #define REINDEXOPT_REPORT_PROGRESS (1 << 1) /* report pgstat progress */
3361
-
3362
3553
  typedef enum ReindexObjectType
3363
3554
  {
3364
3555
  REINDEX_OBJECT_INDEX, /* index */
@@ -3375,8 +3566,7 @@ typedef struct ReindexStmt
3375
3566
  * etc. */
3376
3567
  RangeVar *relation; /* Table or index to reindex */
3377
3568
  const char *name; /* name of database to reindex */
3378
- int options; /* Reindex options flags */
3379
- bool concurrent; /* reindex concurrently? */
3569
+ List *params; /* list of DefElem nodes */
3380
3570
  } ReindexStmt;
3381
3571
 
3382
3572
  /* ----------------------
@@ -3484,7 +3674,7 @@ typedef struct ReassignOwnedStmt
3484
3674
  typedef struct AlterTSDictionaryStmt
3485
3675
  {
3486
3676
  NodeTag type;
3487
- List *dictname; /* qualified name (list of Value strings) */
3677
+ List *dictname; /* qualified name (list of String) */
3488
3678
  List *options; /* List of DefElem nodes */
3489
3679
  } AlterTSDictionaryStmt;
3490
3680
 
@@ -3504,29 +3694,64 @@ typedef struct AlterTSConfigurationStmt
3504
3694
  {
3505
3695
  NodeTag type;
3506
3696
  AlterTSConfigType kind; /* ALTER_TSCONFIG_ADD_MAPPING, etc */
3507
- List *cfgname; /* qualified name (list of Value strings) */
3697
+ List *cfgname; /* qualified name (list of String) */
3508
3698
 
3509
3699
  /*
3510
3700
  * dicts will be non-NIL if ADD/ALTER MAPPING was specified. If dicts is
3511
3701
  * NIL, but tokentype isn't, DROP MAPPING was specified.
3512
3702
  */
3513
- List *tokentype; /* list of Value strings */
3514
- List *dicts; /* list of list of Value strings */
3703
+ List *tokentype; /* list of String */
3704
+ List *dicts; /* list of list of String */
3515
3705
  bool override; /* if true - remove old variant */
3516
3706
  bool replace; /* if true - replace dictionary by another */
3517
3707
  bool missing_ok; /* for DROP - skip error if missing? */
3518
3708
  } AlterTSConfigurationStmt;
3519
3709
 
3710
+ typedef struct PublicationTable
3711
+ {
3712
+ NodeTag type;
3713
+ RangeVar *relation; /* relation to be published */
3714
+ Node *whereClause; /* qualifications */
3715
+ List *columns; /* List of columns in a publication table */
3716
+ } PublicationTable;
3717
+
3718
+ /*
3719
+ * Publication object type
3720
+ */
3721
+ typedef enum PublicationObjSpecType
3722
+ {
3723
+ PUBLICATIONOBJ_TABLE, /* A table */
3724
+ PUBLICATIONOBJ_TABLES_IN_SCHEMA, /* All tables in schema */
3725
+ PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA, /* All tables in first element of
3726
+ * search_path */
3727
+ PUBLICATIONOBJ_CONTINUATION /* Continuation of previous type */
3728
+ } PublicationObjSpecType;
3729
+
3730
+ typedef struct PublicationObjSpec
3731
+ {
3732
+ NodeTag type;
3733
+ PublicationObjSpecType pubobjtype; /* type of this publication object */
3734
+ char *name;
3735
+ PublicationTable *pubtable;
3736
+ int location; /* token location, or -1 if unknown */
3737
+ } PublicationObjSpec;
3520
3738
 
3521
3739
  typedef struct CreatePublicationStmt
3522
3740
  {
3523
3741
  NodeTag type;
3524
3742
  char *pubname; /* Name of the publication */
3525
3743
  List *options; /* List of DefElem nodes */
3526
- List *tables; /* Optional list of tables to add */
3744
+ List *pubobjects; /* Optional list of publication objects */
3527
3745
  bool for_all_tables; /* Special publication for all tables in db */
3528
3746
  } CreatePublicationStmt;
3529
3747
 
3748
+ typedef enum AlterPublicationAction
3749
+ {
3750
+ AP_AddObjects, /* add objects to publication */
3751
+ AP_DropObjects, /* remove objects from publication */
3752
+ AP_SetObjects /* set list of objects */
3753
+ } AlterPublicationAction;
3754
+
3530
3755
  typedef struct AlterPublicationStmt
3531
3756
  {
3532
3757
  NodeTag type;
@@ -3535,10 +3760,14 @@ typedef struct AlterPublicationStmt
3535
3760
  /* parameters used for ALTER PUBLICATION ... WITH */
3536
3761
  List *options; /* List of DefElem nodes */
3537
3762
 
3538
- /* parameters used for ALTER PUBLICATION ... ADD/DROP TABLE */
3539
- List *tables; /* List of tables to add/drop */
3763
+ /*
3764
+ * Parameters used for ALTER PUBLICATION ... ADD/DROP/SET publication
3765
+ * objects.
3766
+ */
3767
+ List *pubobjects; /* Optional list of publication objects */
3540
3768
  bool for_all_tables; /* Special publication for all tables in db */
3541
- DefElemAction tableAction; /* What action to perform with the tables */
3769
+ AlterPublicationAction action; /* What action to perform with the given
3770
+ * objects */
3542
3771
  } AlterPublicationStmt;
3543
3772
 
3544
3773
  typedef struct CreateSubscriptionStmt
@@ -3554,9 +3783,12 @@ typedef enum AlterSubscriptionType
3554
3783
  {
3555
3784
  ALTER_SUBSCRIPTION_OPTIONS,
3556
3785
  ALTER_SUBSCRIPTION_CONNECTION,
3557
- ALTER_SUBSCRIPTION_PUBLICATION,
3786
+ ALTER_SUBSCRIPTION_SET_PUBLICATION,
3787
+ ALTER_SUBSCRIPTION_ADD_PUBLICATION,
3788
+ ALTER_SUBSCRIPTION_DROP_PUBLICATION,
3558
3789
  ALTER_SUBSCRIPTION_REFRESH,
3559
- ALTER_SUBSCRIPTION_ENABLED
3790
+ ALTER_SUBSCRIPTION_ENABLED,
3791
+ ALTER_SUBSCRIPTION_SKIP
3560
3792
  } AlterSubscriptionType;
3561
3793
 
3562
3794
  typedef struct AlterSubscriptionStmt