pg_query 2.1.0 → 4.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (472) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +104 -0
  3. data/README.md +59 -31
  4. data/Rakefile +2 -2
  5. data/ext/pg_query/extconf.rb +8 -2
  6. data/ext/pg_query/include/access/amapi.h +45 -1
  7. data/ext/pg_query/include/access/attmap.h +1 -1
  8. data/ext/pg_query/include/access/attnum.h +2 -2
  9. data/ext/pg_query/include/access/clog.h +4 -2
  10. data/ext/pg_query/include/access/commit_ts.h +6 -9
  11. data/ext/pg_query/include/access/detoast.h +1 -11
  12. data/ext/pg_query/include/access/genam.h +15 -12
  13. data/ext/pg_query/include/access/gin.h +2 -2
  14. data/ext/pg_query/include/access/htup.h +1 -1
  15. data/ext/pg_query/include/access/htup_details.h +75 -87
  16. data/ext/pg_query/include/access/itup.h +7 -1
  17. data/ext/pg_query/include/access/parallel.h +2 -2
  18. data/ext/pg_query/include/access/printtup.h +1 -1
  19. data/ext/pg_query/include/access/relation.h +1 -1
  20. data/ext/pg_query/include/access/relscan.h +17 -2
  21. data/ext/pg_query/include/access/rmgr.h +30 -3
  22. data/ext/pg_query/include/access/rmgrlist.h +23 -23
  23. data/ext/pg_query/include/access/sdir.h +1 -1
  24. data/ext/pg_query/include/access/skey.h +1 -1
  25. data/ext/pg_query/include/access/stratnum.h +4 -2
  26. data/ext/pg_query/include/access/sysattr.h +1 -1
  27. data/ext/pg_query/include/access/table.h +2 -1
  28. data/ext/pg_query/include/access/tableam.h +272 -20
  29. data/ext/pg_query/include/access/toast_compression.h +73 -0
  30. data/ext/pg_query/include/access/transam.h +123 -13
  31. data/ext/pg_query/include/access/tupconvert.h +1 -1
  32. data/ext/pg_query/include/access/tupdesc.h +1 -1
  33. data/ext/pg_query/include/access/tupmacs.h +3 -3
  34. data/ext/pg_query/include/access/twophase.h +5 -1
  35. data/ext/pg_query/include/access/xact.h +79 -19
  36. data/ext/pg_query/include/access/xlog.h +60 -155
  37. data/ext/pg_query/include/access/xlog_internal.h +50 -14
  38. data/ext/pg_query/include/access/xlogdefs.h +8 -16
  39. data/ext/pg_query/include/access/xlogprefetcher.h +55 -0
  40. data/ext/pg_query/include/access/xlogreader.h +148 -32
  41. data/ext/pg_query/include/access/xlogrecord.h +18 -9
  42. data/ext/pg_query/include/access/xlogrecovery.h +157 -0
  43. data/ext/pg_query/include/c.h +101 -44
  44. data/ext/pg_query/include/catalog/catalog.h +3 -1
  45. data/ext/pg_query/include/catalog/catversion.h +2 -2
  46. data/ext/pg_query/include/catalog/dependency.h +10 -16
  47. data/ext/pg_query/include/catalog/genbki.h +83 -5
  48. data/ext/pg_query/include/catalog/index.h +18 -3
  49. data/ext/pg_query/include/catalog/indexing.h +12 -324
  50. data/ext/pg_query/include/catalog/namespace.h +4 -2
  51. data/ext/pg_query/include/catalog/objectaccess.h +70 -2
  52. data/ext/pg_query/include/catalog/objectaddress.h +11 -6
  53. data/ext/pg_query/include/catalog/pg_aggregate.h +14 -10
  54. data/ext/pg_query/include/catalog/pg_aggregate_d.h +2 -1
  55. data/ext/pg_query/include/catalog/pg_am.h +4 -1
  56. data/ext/pg_query/include/catalog/pg_am_d.h +3 -1
  57. data/ext/pg_query/include/catalog/pg_attribute.h +27 -10
  58. data/ext/pg_query/include/catalog/pg_attribute_d.h +21 -18
  59. data/ext/pg_query/include/catalog/pg_authid.h +7 -2
  60. data/ext/pg_query/include/catalog/pg_authid_d.h +17 -9
  61. data/ext/pg_query/include/catalog/pg_class.h +45 -15
  62. data/ext/pg_query/include/catalog/pg_class_d.h +31 -2
  63. data/ext/pg_query/include/catalog/pg_collation.h +33 -8
  64. data/ext/pg_query/include/catalog/pg_collation_d.h +20 -3
  65. data/ext/pg_query/include/catalog/pg_constraint.h +38 -12
  66. data/ext/pg_query/include/catalog/pg_constraint_d.h +10 -4
  67. data/ext/pg_query/include/catalog/pg_control.h +5 -5
  68. data/ext/pg_query/include/catalog/pg_conversion.h +7 -4
  69. data/ext/pg_query/include/catalog/pg_conversion_d.h +4 -1
  70. data/ext/pg_query/include/catalog/pg_depend.h +11 -7
  71. data/ext/pg_query/include/catalog/pg_depend_d.h +3 -1
  72. data/ext/pg_query/include/catalog/pg_event_trigger.h +9 -3
  73. data/ext/pg_query/include/catalog/pg_event_trigger_d.h +3 -1
  74. data/ext/pg_query/include/catalog/pg_index.h +17 -7
  75. data/ext/pg_query/include/catalog/pg_index_d.h +20 -17
  76. data/ext/pg_query/include/catalog/pg_language.h +10 -5
  77. data/ext/pg_query/include/catalog/pg_language_d.h +3 -1
  78. data/ext/pg_query/include/catalog/pg_namespace.h +7 -2
  79. data/ext/pg_query/include/catalog/pg_namespace_d.h +3 -1
  80. data/ext/pg_query/include/catalog/pg_opclass.h +8 -5
  81. data/ext/pg_query/include/catalog/pg_opclass_d.h +3 -1
  82. data/ext/pg_query/include/catalog/pg_operator.h +21 -16
  83. data/ext/pg_query/include/catalog/pg_operator_d.h +37 -1
  84. data/ext/pg_query/include/catalog/pg_opfamily.h +6 -3
  85. data/ext/pg_query/include/catalog/pg_opfamily_d.h +3 -1
  86. data/ext/pg_query/include/catalog/pg_parameter_acl.h +60 -0
  87. data/ext/pg_query/include/catalog/pg_parameter_acl_d.h +34 -0
  88. data/ext/pg_query/include/catalog/pg_partitioned_table.h +20 -9
  89. data/ext/pg_query/include/catalog/pg_partitioned_table_d.h +2 -1
  90. data/ext/pg_query/include/catalog/pg_proc.h +20 -11
  91. data/ext/pg_query/include/catalog/pg_proc_d.h +10 -8
  92. data/ext/pg_query/include/catalog/pg_publication.h +50 -4
  93. data/ext/pg_query/include/catalog/pg_publication_d.h +3 -1
  94. data/ext/pg_query/include/catalog/pg_replication_origin.h +6 -1
  95. data/ext/pg_query/include/catalog/pg_replication_origin_d.h +5 -1
  96. data/ext/pg_query/include/catalog/pg_statistic.h +19 -12
  97. data/ext/pg_query/include/catalog/pg_statistic_d.h +2 -1
  98. data/ext/pg_query/include/catalog/pg_statistic_ext.h +19 -5
  99. data/ext/pg_query/include/catalog/pg_statistic_ext_d.h +7 -2
  100. data/ext/pg_query/include/catalog/pg_transform.h +8 -5
  101. data/ext/pg_query/include/catalog/pg_transform_d.h +3 -1
  102. data/ext/pg_query/include/catalog/pg_trigger.h +24 -8
  103. data/ext/pg_query/include/catalog/pg_trigger_d.h +4 -1
  104. data/ext/pg_query/include/catalog/pg_ts_config.h +6 -3
  105. data/ext/pg_query/include/catalog/pg_ts_config_d.h +3 -1
  106. data/ext/pg_query/include/catalog/pg_ts_dict.h +8 -3
  107. data/ext/pg_query/include/catalog/pg_ts_dict_d.h +3 -1
  108. data/ext/pg_query/include/catalog/pg_ts_parser.h +6 -3
  109. data/ext/pg_query/include/catalog/pg_ts_parser_d.h +3 -1
  110. data/ext/pg_query/include/catalog/pg_ts_template.h +6 -3
  111. data/ext/pg_query/include/catalog/pg_ts_template_d.h +3 -1
  112. data/ext/pg_query/include/catalog/pg_type.h +56 -24
  113. data/ext/pg_query/include/catalog/pg_type_d.h +70 -31
  114. data/ext/pg_query/include/catalog/storage.h +5 -3
  115. data/ext/pg_query/include/commands/async.h +4 -5
  116. data/ext/pg_query/include/commands/dbcommands.h +2 -1
  117. data/ext/pg_query/include/commands/defrem.h +11 -24
  118. data/ext/pg_query/include/commands/event_trigger.h +2 -2
  119. data/ext/pg_query/include/commands/explain.h +1 -1
  120. data/ext/pg_query/include/commands/prepare.h +1 -1
  121. data/ext/pg_query/include/commands/tablespace.h +3 -1
  122. data/ext/pg_query/include/commands/trigger.h +27 -17
  123. data/ext/pg_query/include/commands/user.h +2 -2
  124. data/ext/pg_query/include/commands/vacuum.h +88 -41
  125. data/ext/pg_query/include/commands/variable.h +1 -1
  126. data/ext/pg_query/include/common/file_perm.h +4 -4
  127. data/ext/pg_query/include/common/hashfn.h +1 -1
  128. data/ext/pg_query/include/common/ip.h +1 -7
  129. data/ext/pg_query/include/common/keywords.h +2 -6
  130. data/ext/pg_query/include/common/kwlookup.h +1 -1
  131. data/ext/pg_query/include/common/pg_prng.h +60 -0
  132. data/ext/pg_query/include/common/relpath.h +2 -2
  133. data/ext/pg_query/include/common/string.h +24 -1
  134. data/ext/pg_query/include/common/unicode_combining_table.h +114 -2
  135. data/ext/pg_query/include/common/unicode_east_asian_fw_table.h +125 -0
  136. data/ext/pg_query/include/datatype/timestamp.h +40 -1
  137. data/ext/pg_query/include/executor/execdesc.h +1 -1
  138. data/ext/pg_query/include/executor/executor.h +65 -22
  139. data/ext/pg_query/include/executor/functions.h +17 -3
  140. data/ext/pg_query/include/executor/instrument.h +33 -16
  141. data/ext/pg_query/include/executor/spi.h +41 -3
  142. data/ext/pg_query/include/executor/tablefunc.h +1 -1
  143. data/ext/pg_query/include/executor/tuptable.h +1 -1
  144. data/ext/pg_query/include/fmgr.h +13 -7
  145. data/ext/pg_query/include/funcapi.h +16 -4
  146. data/ext/pg_query/include/getaddrinfo.h +1 -1
  147. data/ext/pg_query/include/jit/jit.h +11 -11
  148. data/ext/pg_query/include/kwlist_d.h +517 -494
  149. data/ext/pg_query/include/lib/dshash.h +112 -0
  150. data/ext/pg_query/include/lib/ilist.h +20 -1
  151. data/ext/pg_query/include/lib/pairingheap.h +1 -1
  152. data/ext/pg_query/include/lib/simplehash.h +150 -25
  153. data/ext/pg_query/include/lib/sort_template.h +432 -0
  154. data/ext/pg_query/include/lib/stringinfo.h +1 -1
  155. data/ext/pg_query/include/libpq/auth.h +6 -4
  156. data/ext/pg_query/include/libpq/crypt.h +5 -4
  157. data/ext/pg_query/include/libpq/hba.h +43 -4
  158. data/ext/pg_query/include/libpq/libpq-be.h +23 -6
  159. data/ext/pg_query/include/libpq/libpq.h +31 -20
  160. data/ext/pg_query/include/libpq/pqcomm.h +17 -31
  161. data/ext/pg_query/include/libpq/pqformat.h +1 -1
  162. data/ext/pg_query/include/libpq/pqsignal.h +4 -4
  163. data/ext/pg_query/include/mb/pg_wchar.h +106 -23
  164. data/ext/pg_query/include/mb/stringinfo_mb.h +1 -1
  165. data/ext/pg_query/include/miscadmin.h +71 -52
  166. data/ext/pg_query/include/nodes/bitmapset.h +1 -1
  167. data/ext/pg_query/include/nodes/execnodes.h +272 -80
  168. data/ext/pg_query/include/nodes/extensible.h +4 -2
  169. data/ext/pg_query/include/nodes/lockoptions.h +1 -1
  170. data/ext/pg_query/include/nodes/makefuncs.h +7 -6
  171. data/ext/pg_query/include/nodes/memnodes.h +5 -3
  172. data/ext/pg_query/include/nodes/nodeFuncs.h +1 -1
  173. data/ext/pg_query/include/nodes/nodes.h +30 -11
  174. data/ext/pg_query/include/nodes/params.h +1 -1
  175. data/ext/pg_query/include/nodes/parsenodes.h +327 -94
  176. data/ext/pg_query/include/nodes/pathnodes.h +245 -67
  177. data/ext/pg_query/include/nodes/pg_list.h +75 -68
  178. data/ext/pg_query/include/nodes/plannodes.h +128 -30
  179. data/ext/pg_query/include/nodes/primnodes.h +99 -47
  180. data/ext/pg_query/include/nodes/print.h +1 -1
  181. data/ext/pg_query/include/nodes/tidbitmap.h +1 -1
  182. data/ext/pg_query/include/nodes/value.h +58 -39
  183. data/ext/pg_query/include/optimizer/cost.h +9 -2
  184. data/ext/pg_query/include/optimizer/geqo.h +9 -7
  185. data/ext/pg_query/include/optimizer/geqo_gene.h +1 -1
  186. data/ext/pg_query/include/optimizer/optimizer.h +25 -22
  187. data/ext/pg_query/include/optimizer/paths.h +6 -6
  188. data/ext/pg_query/include/optimizer/planmain.h +15 -14
  189. data/ext/pg_query/include/parser/analyze.h +19 -5
  190. data/ext/pg_query/include/parser/gram.h +947 -913
  191. data/ext/pg_query/include/parser/gramparse.h +1 -1
  192. data/ext/pg_query/include/parser/kwlist.h +463 -453
  193. data/ext/pg_query/include/parser/parse_agg.h +2 -7
  194. data/ext/pg_query/include/parser/parse_coerce.h +4 -1
  195. data/ext/pg_query/include/parser/parse_expr.h +2 -3
  196. data/ext/pg_query/include/parser/parse_func.h +2 -1
  197. data/ext/pg_query/include/parser/parse_node.h +21 -9
  198. data/ext/pg_query/include/parser/parse_oper.h +1 -3
  199. data/ext/pg_query/include/parser/parse_relation.h +5 -4
  200. data/ext/pg_query/include/parser/parse_type.h +1 -1
  201. data/ext/pg_query/include/parser/parser.h +31 -4
  202. data/ext/pg_query/include/parser/parsetree.h +1 -1
  203. data/ext/pg_query/include/parser/scanner.h +1 -1
  204. data/ext/pg_query/include/parser/scansup.h +2 -5
  205. data/ext/pg_query/include/partitioning/partdefs.h +1 -1
  206. data/ext/pg_query/include/pg_config.h +94 -46
  207. data/ext/pg_query/include/pg_config_manual.h +74 -21
  208. data/ext/pg_query/include/pg_getopt.h +6 -6
  209. data/ext/pg_query/include/pg_query.h +5 -4
  210. data/ext/pg_query/include/pg_query_enum_defs.c +358 -241
  211. data/ext/pg_query/include/pg_query_fingerprint_conds.c +44 -7
  212. data/ext/pg_query/include/pg_query_fingerprint_defs.c +1220 -422
  213. data/ext/pg_query/include/pg_query_outfuncs_conds.c +43 -13
  214. data/ext/pg_query/include/pg_query_outfuncs_defs.c +152 -26
  215. data/ext/pg_query/include/pg_query_readfuncs_conds.c +11 -2
  216. data/ext/pg_query/include/pg_query_readfuncs_defs.c +174 -30
  217. data/ext/pg_query/include/pg_trace.h +1 -1
  218. data/ext/pg_query/include/pgstat.h +449 -1237
  219. data/ext/pg_query/include/pgtime.h +14 -4
  220. data/ext/pg_query/include/pl_gram.h +126 -128
  221. data/ext/pg_query/include/pl_reserved_kwlist.h +1 -1
  222. data/ext/pg_query/include/pl_reserved_kwlist_d.h +10 -10
  223. data/ext/pg_query/include/pl_unreserved_kwlist.h +2 -3
  224. data/ext/pg_query/include/pl_unreserved_kwlist_d.h +54 -56
  225. data/ext/pg_query/include/plerrcodes.h +9 -1
  226. data/ext/pg_query/include/plpgsql.h +52 -54
  227. data/ext/pg_query/include/port/atomics/arch-arm.h +7 -1
  228. data/ext/pg_query/include/port/atomics/arch-ppc.h +1 -1
  229. data/ext/pg_query/include/port/atomics/arch-x86.h +1 -1
  230. data/ext/pg_query/include/port/atomics/fallback.h +1 -1
  231. data/ext/pg_query/include/port/atomics/generic-gcc.h +3 -3
  232. data/ext/pg_query/include/port/atomics/generic.h +1 -1
  233. data/ext/pg_query/include/port/atomics.h +1 -1
  234. data/ext/pg_query/include/port/pg_bitutils.h +88 -12
  235. data/ext/pg_query/include/port/pg_bswap.h +1 -1
  236. data/ext/pg_query/include/port/pg_crc32c.h +1 -1
  237. data/ext/pg_query/include/port.h +72 -43
  238. data/ext/pg_query/include/portability/instr_time.h +1 -1
  239. data/ext/pg_query/include/postgres.h +60 -16
  240. data/ext/pg_query/include/postmaster/autovacuum.h +17 -17
  241. data/ext/pg_query/include/postmaster/auxprocess.h +20 -0
  242. data/ext/pg_query/include/postmaster/bgworker.h +2 -1
  243. data/ext/pg_query/include/postmaster/bgworker_internals.h +2 -2
  244. data/ext/pg_query/include/postmaster/bgwriter.h +5 -5
  245. data/ext/pg_query/include/postmaster/fork_process.h +1 -1
  246. data/ext/pg_query/include/postmaster/interrupt.h +1 -1
  247. data/ext/pg_query/include/postmaster/pgarch.h +42 -8
  248. data/ext/pg_query/include/postmaster/postmaster.h +18 -17
  249. data/ext/pg_query/include/postmaster/startup.h +39 -0
  250. data/ext/pg_query/include/postmaster/syslogger.h +15 -10
  251. data/ext/pg_query/include/postmaster/walwriter.h +3 -3
  252. data/ext/pg_query/include/protobuf/pg_query.pb-c.h +1422 -916
  253. data/ext/pg_query/include/protobuf/pg_query.pb.h +43678 -32769
  254. data/ext/pg_query/include/regex/regex.h +18 -16
  255. data/ext/pg_query/include/replication/logicallauncher.h +3 -5
  256. data/ext/pg_query/include/replication/logicalproto.h +161 -17
  257. data/ext/pg_query/include/replication/logicalworker.h +1 -1
  258. data/ext/pg_query/include/replication/origin.h +7 -7
  259. data/ext/pg_query/include/replication/reorderbuffer.h +262 -44
  260. data/ext/pg_query/include/replication/slot.h +23 -12
  261. data/ext/pg_query/include/replication/syncrep.h +5 -5
  262. data/ext/pg_query/include/replication/walreceiver.h +145 -13
  263. data/ext/pg_query/include/replication/walsender.h +8 -8
  264. data/ext/pg_query/include/rewrite/prs2lock.h +1 -1
  265. data/ext/pg_query/include/rewrite/rewriteHandler.h +1 -3
  266. data/ext/pg_query/include/rewrite/rewriteManip.h +1 -1
  267. data/ext/pg_query/include/rewrite/rewriteSupport.h +1 -1
  268. data/ext/pg_query/include/storage/backendid.h +3 -3
  269. data/ext/pg_query/include/storage/block.h +4 -10
  270. data/ext/pg_query/include/storage/buf.h +1 -1
  271. data/ext/pg_query/include/storage/bufmgr.h +19 -14
  272. data/ext/pg_query/include/storage/bufpage.h +6 -8
  273. data/ext/pg_query/include/storage/condition_variable.h +13 -2
  274. data/ext/pg_query/include/storage/dsm.h +4 -1
  275. data/ext/pg_query/include/storage/dsm_impl.h +3 -2
  276. data/ext/pg_query/include/storage/fd.h +33 -3
  277. data/ext/pg_query/include/storage/fileset.h +40 -0
  278. data/ext/pg_query/include/storage/ipc.h +4 -1
  279. data/ext/pg_query/include/storage/item.h +1 -1
  280. data/ext/pg_query/include/storage/itemid.h +1 -1
  281. data/ext/pg_query/include/storage/itemptr.h +3 -1
  282. data/ext/pg_query/include/storage/large_object.h +2 -2
  283. data/ext/pg_query/include/storage/latch.h +9 -13
  284. data/ext/pg_query/include/storage/lmgr.h +2 -1
  285. data/ext/pg_query/include/storage/lock.h +17 -13
  286. data/ext/pg_query/include/storage/lockdefs.h +2 -2
  287. data/ext/pg_query/include/storage/lwlock.h +6 -32
  288. data/ext/pg_query/include/storage/lwlocknames.h +0 -1
  289. data/ext/pg_query/include/storage/off.h +1 -1
  290. data/ext/pg_query/include/storage/pg_sema.h +1 -1
  291. data/ext/pg_query/include/storage/pg_shmem.h +9 -7
  292. data/ext/pg_query/include/storage/pmsignal.h +15 -4
  293. data/ext/pg_query/include/storage/predicate.h +4 -4
  294. data/ext/pg_query/include/storage/proc.h +183 -55
  295. data/ext/pg_query/include/storage/procarray.h +98 -0
  296. data/ext/pg_query/include/storage/proclist_types.h +1 -1
  297. data/ext/pg_query/include/storage/procsignal.h +3 -7
  298. data/ext/pg_query/include/storage/relfilenode.h +1 -1
  299. data/ext/pg_query/include/storage/s_lock.h +67 -4
  300. data/ext/pg_query/include/storage/sharedfileset.h +3 -11
  301. data/ext/pg_query/include/storage/shm_mq.h +5 -4
  302. data/ext/pg_query/include/storage/shm_toc.h +1 -1
  303. data/ext/pg_query/include/storage/shmem.h +1 -1
  304. data/ext/pg_query/include/storage/sinval.h +3 -3
  305. data/ext/pg_query/include/storage/sinvaladt.h +1 -1
  306. data/ext/pg_query/include/storage/smgr.h +10 -8
  307. data/ext/pg_query/include/storage/spin.h +2 -2
  308. data/ext/pg_query/include/storage/standby.h +13 -6
  309. data/ext/pg_query/include/storage/standbydefs.h +2 -2
  310. data/ext/pg_query/include/storage/sync.h +7 -3
  311. data/ext/pg_query/include/tcop/cmdtag.h +1 -1
  312. data/ext/pg_query/include/tcop/cmdtaglist.h +3 -2
  313. data/ext/pg_query/include/tcop/deparse_utility.h +1 -1
  314. data/ext/pg_query/include/tcop/dest.h +1 -1
  315. data/ext/pg_query/include/tcop/fastpath.h +1 -2
  316. data/ext/pg_query/include/tcop/pquery.h +7 -1
  317. data/ext/pg_query/include/tcop/tcopprot.h +19 -11
  318. data/ext/pg_query/include/tcop/utility.h +7 -3
  319. data/ext/pg_query/include/tsearch/ts_cache.h +2 -2
  320. data/ext/pg_query/include/utils/acl.h +24 -3
  321. data/ext/pg_query/include/utils/aclchk_internal.h +1 -1
  322. data/ext/pg_query/include/utils/array.h +7 -2
  323. data/ext/pg_query/include/utils/backend_progress.h +44 -0
  324. data/ext/pg_query/include/utils/backend_status.h +321 -0
  325. data/ext/pg_query/include/utils/builtins.h +11 -11
  326. data/ext/pg_query/include/utils/bytea.h +3 -2
  327. data/ext/pg_query/include/utils/catcache.h +1 -1
  328. data/ext/pg_query/include/utils/date.h +1 -1
  329. data/ext/pg_query/include/utils/datetime.h +8 -7
  330. data/ext/pg_query/include/utils/datum.h +9 -1
  331. data/ext/pg_query/include/utils/dsa.h +1 -1
  332. data/ext/pg_query/include/utils/dynahash.h +4 -3
  333. data/ext/pg_query/include/utils/elog.h +52 -21
  334. data/ext/pg_query/include/utils/errcodes.h +2 -0
  335. data/ext/pg_query/include/utils/expandeddatum.h +1 -1
  336. data/ext/pg_query/include/utils/expandedrecord.h +1 -1
  337. data/ext/pg_query/include/utils/float.h +7 -7
  338. data/ext/pg_query/include/utils/fmgroids.h +1300 -696
  339. data/ext/pg_query/include/utils/fmgrprotos.h +199 -16
  340. data/ext/pg_query/include/utils/fmgrtab.h +6 -5
  341. data/ext/pg_query/include/utils/guc.h +69 -43
  342. data/ext/pg_query/include/utils/guc_tables.h +23 -19
  343. data/ext/pg_query/include/utils/hsearch.h +15 -11
  344. data/ext/pg_query/include/utils/inval.h +5 -1
  345. data/ext/pg_query/include/utils/lsyscache.h +11 -1
  346. data/ext/pg_query/include/utils/memdebug.h +1 -1
  347. data/ext/pg_query/include/utils/memutils.h +8 -3
  348. data/ext/pg_query/include/utils/numeric.h +19 -5
  349. data/ext/pg_query/include/utils/palloc.h +25 -3
  350. data/ext/pg_query/include/utils/partcache.h +1 -1
  351. data/ext/pg_query/include/utils/pg_locale.h +17 -9
  352. data/ext/pg_query/include/utils/pg_lsn.h +1 -1
  353. data/ext/pg_query/include/utils/pgstat_internal.h +784 -0
  354. data/ext/pg_query/include/utils/pidfile.h +1 -1
  355. data/ext/pg_query/include/utils/plancache.h +6 -5
  356. data/ext/pg_query/include/utils/portal.h +12 -1
  357. data/ext/pg_query/include/utils/ps_status.h +1 -1
  358. data/ext/pg_query/include/utils/queryenvironment.h +1 -1
  359. data/ext/pg_query/include/utils/queryjumble.h +88 -0
  360. data/ext/pg_query/include/utils/regproc.h +14 -3
  361. data/ext/pg_query/include/utils/rel.h +71 -20
  362. data/ext/pg_query/include/utils/relcache.h +9 -7
  363. data/ext/pg_query/include/utils/reltrigger.h +1 -1
  364. data/ext/pg_query/include/utils/resowner.h +1 -1
  365. data/ext/pg_query/include/utils/rls.h +2 -2
  366. data/ext/pg_query/include/utils/ruleutils.h +4 -1
  367. data/ext/pg_query/include/utils/sharedtuplestore.h +1 -1
  368. data/ext/pg_query/include/utils/snapmgr.h +35 -14
  369. data/ext/pg_query/include/utils/snapshot.h +14 -1
  370. data/ext/pg_query/include/utils/sortsupport.h +117 -2
  371. data/ext/pg_query/include/utils/syscache.h +6 -1
  372. data/ext/pg_query/include/utils/timeout.h +11 -4
  373. data/ext/pg_query/include/utils/timestamp.h +6 -5
  374. data/ext/pg_query/include/utils/tuplesort.h +25 -11
  375. data/ext/pg_query/include/utils/tuplestore.h +2 -2
  376. data/ext/pg_query/include/utils/typcache.h +24 -17
  377. data/ext/pg_query/include/utils/tzparser.h +1 -1
  378. data/ext/pg_query/include/utils/varlena.h +5 -3
  379. data/ext/pg_query/include/utils/wait_event.h +289 -0
  380. data/ext/pg_query/include/utils/xml.h +4 -4
  381. data/ext/pg_query/pg_query.pb-c.c +4318 -2307
  382. data/ext/pg_query/pg_query_deparse.c +1114 -381
  383. data/ext/pg_query/pg_query_fingerprint.c +46 -10
  384. data/ext/pg_query/pg_query_fingerprint.h +3 -1
  385. data/ext/pg_query/pg_query_json_plpgsql.c +55 -12
  386. data/ext/pg_query/pg_query_normalize.c +163 -20
  387. data/ext/pg_query/pg_query_outfuncs.h +1 -0
  388. data/ext/pg_query/pg_query_outfuncs_json.c +65 -16
  389. data/ext/pg_query/pg_query_outfuncs_protobuf.c +70 -10
  390. data/ext/pg_query/pg_query_parse.c +1 -1
  391. data/ext/pg_query/pg_query_parse_plpgsql.c +79 -16
  392. data/ext/pg_query/pg_query_readfuncs_protobuf.c +42 -8
  393. data/ext/pg_query/pg_query_ruby.c +1 -1
  394. data/ext/pg_query/pg_query_scan.c +2 -1
  395. data/ext/pg_query/pg_query_split.c +3 -2
  396. data/ext/pg_query/src_backend_catalog_namespace.c +21 -9
  397. data/ext/pg_query/src_backend_catalog_pg_proc.c +4 -1
  398. data/ext/pg_query/src_backend_commands_define.c +11 -1
  399. data/ext/pg_query/src_backend_nodes_bitmapset.c +3 -1
  400. data/ext/pg_query/src_backend_nodes_copyfuncs.c +424 -109
  401. data/ext/pg_query/src_backend_nodes_equalfuncs.c +291 -46
  402. data/ext/pg_query/src_backend_nodes_extensible.c +1 -1
  403. data/ext/pg_query/src_backend_nodes_list.c +86 -11
  404. data/ext/pg_query/src_backend_nodes_makefuncs.c +5 -4
  405. data/ext/pg_query/src_backend_nodes_nodeFuncs.c +55 -12
  406. data/ext/pg_query/src_backend_nodes_value.c +28 -19
  407. data/ext/pg_query/src_backend_parser_gram.c +33890 -31262
  408. data/ext/pg_query/src_backend_parser_parser.c +26 -7
  409. data/ext/pg_query/src_backend_parser_scan.c +644 -441
  410. data/ext/pg_query/src_backend_parser_scansup.c +4 -28
  411. data/ext/pg_query/src_backend_postmaster_postmaster.c +77 -106
  412. data/ext/pg_query/src_backend_storage_ipc_ipc.c +13 -4
  413. data/ext/pg_query/src_backend_storage_lmgr_s_lock.c +5 -4
  414. data/ext/pg_query/src_backend_tcop_postgres.c +73 -24
  415. data/ext/pg_query/src_backend_utils_activity_pgstat_database.c +140 -0
  416. data/ext/pg_query/src_backend_utils_adt_datum.c +13 -1
  417. data/ext/pg_query/src_backend_utils_adt_expandeddatum.c +1 -1
  418. data/ext/pg_query/src_backend_utils_adt_format_type.c +6 -2
  419. data/ext/pg_query/src_backend_utils_adt_ruleutils.c +109 -15
  420. data/ext/pg_query/src_backend_utils_error_assert.c +16 -14
  421. data/ext/pg_query/src_backend_utils_error_elog.c +172 -99
  422. data/ext/pg_query/src_backend_utils_fmgr_fmgr.c +12 -17
  423. data/ext/pg_query/src_backend_utils_hash_dynahash.c +40 -10
  424. data/ext/pg_query/src_backend_utils_init_globals.c +5 -5
  425. data/ext/pg_query/src_backend_utils_mb_mbutils.c +55 -66
  426. data/ext/pg_query/src_backend_utils_misc_guc.c +207 -45
  427. data/ext/pg_query/src_backend_utils_mmgr_aset.c +7 -5
  428. data/ext/pg_query/src_backend_utils_mmgr_mcxt.c +123 -35
  429. data/ext/pg_query/src_common_encnames.c +1 -1
  430. data/ext/pg_query/src_common_hashfn.c +3 -3
  431. data/ext/pg_query/src_common_keywords.c +15 -2
  432. data/ext/pg_query/src_common_kwlist_d.h +517 -494
  433. data/ext/pg_query/src_common_kwlookup.c +1 -1
  434. data/ext/pg_query/src_common_pg_prng.c +152 -0
  435. data/ext/pg_query/src_common_psprintf.c +1 -1
  436. data/ext/pg_query/src_common_string.c +7 -1
  437. data/ext/pg_query/src_common_stringinfo.c +1 -1
  438. data/ext/pg_query/src_common_wchar.c +712 -109
  439. data/ext/pg_query/src_pl_plpgsql_src_pl_comp.c +49 -22
  440. data/ext/pg_query/src_pl_plpgsql_src_pl_funcs.c +1 -18
  441. data/ext/pg_query/src_pl_plpgsql_src_pl_gram.c +1235 -1261
  442. data/ext/pg_query/src_pl_plpgsql_src_pl_handler.c +1 -1
  443. data/ext/pg_query/src_pl_plpgsql_src_pl_reserved_kwlist_d.h +10 -10
  444. data/ext/pg_query/src_pl_plpgsql_src_pl_scanner.c +2 -2
  445. data/ext/pg_query/src_pl_plpgsql_src_pl_unreserved_kwlist_d.h +54 -56
  446. data/ext/pg_query/src_port_pg_bitutils.c +41 -52
  447. data/ext/pg_query/src_port_pgsleep.c +1 -1
  448. data/ext/pg_query/src_port_pgstrcasecmp.c +1 -1
  449. data/ext/pg_query/src_port_qsort.c +12 -224
  450. data/ext/pg_query/src_port_snprintf.c +46 -20
  451. data/ext/pg_query/src_port_strerror.c +9 -19
  452. data/ext/pg_query/src_port_strnlen.c +1 -1
  453. data/lib/pg_query/deparse.rb +7 -1
  454. data/lib/pg_query/filter_columns.rb +6 -4
  455. data/lib/pg_query/fingerprint.rb +18 -3
  456. data/lib/pg_query/node.rb +2 -2
  457. data/lib/pg_query/param_refs.rb +1 -1
  458. data/lib/pg_query/parse.rb +87 -51
  459. data/lib/pg_query/pg_query_pb.rb +1109 -942
  460. data/lib/pg_query/treewalker.rb +6 -0
  461. data/lib/pg_query/truncate.rb +54 -8
  462. data/lib/pg_query/version.rb +1 -1
  463. metadata +29 -18
  464. data/ext/pg_query/include/access/xloginsert.h +0 -64
  465. data/ext/pg_query/include/bootstrap/bootstrap.h +0 -62
  466. data/ext/pg_query/include/parser/parse_clause.h +0 -54
  467. data/ext/pg_query/include/parser/parse_collate.h +0 -27
  468. data/ext/pg_query/include/parser/parse_target.h +0 -46
  469. data/ext/pg_query/src_backend_libpq_pqcomm.c +0 -651
  470. data/ext/pg_query/src_backend_parser_parse_expr.c +0 -313
  471. data/ext/pg_query/src_port_erand48.c +0 -127
  472. 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
  /****************************************************************************
@@ -915,10 +950,10 @@ typedef struct PartitionCmd
915
950
  * inFromCl marks those range variables that are listed in the FROM clause.
916
951
  * It's false for RTEs that are added to a query behind the scenes, such
917
952
  * as the NEW and OLD variables for a rule, or the subqueries of a UNION.
918
- * This flag is not used anymore during parsing, since the parser now uses
919
- * a separate "namespace" data structure to control visibility, but it is
920
- * needed by ruleutils.c to determine whether RTEs should be shown in
921
- * decompiled queries.
953
+ * This flag is not used during parsing (except in transformLockingClause,
954
+ * q.v.); the parser now uses a separate "namespace" data structure to
955
+ * control visibility. But it is needed by ruleutils.c to determine
956
+ * whether RTEs should be shown in decompiled queries.
922
957
  *
923
958
  * requiredPerms and checkAsUser specify run-time access permissions
924
959
  * checks to be performed at query startup. The user must have *all*
@@ -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
@@ -1876,6 +2030,7 @@ typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */
1876
2030
  * constraint, or parent table */
1877
2031
  DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
1878
2032
  bool missing_ok; /* skip error if missing? */
2033
+ bool recurse; /* exec-time recursion */
1879
2034
  } AlterTableCmd;
1880
2035
 
1881
2036
 
@@ -1934,27 +2089,39 @@ typedef struct GrantStmt
1934
2089
  GrantTargetType targtype; /* type of the grant target */
1935
2090
  ObjectType objtype; /* kind of object being operated on */
1936
2091
  List *objects; /* list of RangeVar nodes, ObjectWithArgs
1937
- * nodes, or plain names (as Value strings) */
2092
+ * nodes, or plain names (as String values) */
1938
2093
  List *privileges; /* list of AccessPriv nodes */
1939
2094
  /* privileges == NIL denotes ALL PRIVILEGES */
1940
2095
  List *grantees; /* list of RoleSpec nodes */
1941
2096
  bool grant_option; /* grant or revoke grant option */
2097
+ RoleSpec *grantor;
1942
2098
  DropBehavior behavior; /* drop behavior (for REVOKE) */
1943
2099
  } GrantStmt;
1944
2100
 
1945
2101
  /*
1946
- * Note: ObjectWithArgs carries only the types of the input parameters of the
1947
- * function. So it is sufficient to identify an existing function, but it
1948
- * 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.
1949
2117
  */
1950
2118
  typedef struct ObjectWithArgs
1951
2119
  {
1952
2120
  NodeTag type;
1953
2121
  List *objname; /* qualified name of function/operator */
1954
- List *objargs; /* list of Typename nodes */
1955
- bool args_unspecified; /* argument list was omitted, so name must
1956
- * be unique (note that objargs == NIL
1957
- * 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? */
1958
2125
  } ObjectWithArgs;
1959
2126
 
1960
2127
  /*
@@ -1968,7 +2135,7 @@ typedef struct AccessPriv
1968
2135
  {
1969
2136
  NodeTag type;
1970
2137
  char *priv_name; /* string name of privilege */
1971
- List *cols; /* list of Value strings */
2138
+ List *cols; /* list of String */
1972
2139
  } AccessPriv;
1973
2140
 
1974
2141
  /* ----------------------
@@ -1977,7 +2144,7 @@ typedef struct AccessPriv
1977
2144
  * Note: because of the parsing ambiguity with the GRANT <privileges>
1978
2145
  * statement, granted_roles is a list of AccessPriv; the execution code
1979
2146
  * should complain if any column lists appear. grantee_roles is a list
1980
- * of role names, as Value strings.
2147
+ * of role names, as String values.
1981
2148
  * ----------------------
1982
2149
  */
1983
2150
  typedef struct GrantRoleStmt
@@ -2032,7 +2199,7 @@ typedef struct CopyStmt
2032
2199
  * preserve the distinction in VariableSetKind for CreateCommandTag().
2033
2200
  * ----------------------
2034
2201
  */
2035
- typedef enum
2202
+ typedef enum VariableSetKind
2036
2203
  {
2037
2204
  VAR_SET_VALUE, /* SET var = value */
2038
2205
  VAR_SET_DEFAULT, /* SET var TO DEFAULT */
@@ -2078,7 +2245,7 @@ typedef struct CreateStmt
2078
2245
  RangeVar *relation; /* relation to create */
2079
2246
  List *tableElts; /* column definitions (list of ColumnDef) */
2080
2247
  List *inhRelations; /* relations to inherit from (list of
2081
- * inhRelation) */
2248
+ * RangeVar) */
2082
2249
  PartitionBoundSpec *partbound; /* FOR VALUES clause */
2083
2250
  PartitionSpec *partspec; /* PARTITION BY clause */
2084
2251
  TypeName *ofTypename; /* OF typename */
@@ -2170,6 +2337,7 @@ typedef struct Constraint
2170
2337
  char generated_when; /* ALWAYS or BY DEFAULT */
2171
2338
 
2172
2339
  /* Fields used for unique constraints (UNIQUE and PRIMARY KEY): */
2340
+ bool nulls_not_distinct; /* null treatment for UNIQUE constraints */
2173
2341
  List *keys; /* String nodes naming referenced key
2174
2342
  * column(s) */
2175
2343
  List *including; /* String nodes naming referenced nonkey
@@ -2195,6 +2363,7 @@ typedef struct Constraint
2195
2363
  char fk_matchtype; /* FULL, PARTIAL, SIMPLE */
2196
2364
  char fk_upd_action; /* ON UPDATE action */
2197
2365
  char fk_del_action; /* ON DELETE action */
2366
+ List *fk_del_set_cols; /* ON DELETE SET NULL/DEFAULT (col1, col2) */
2198
2367
  List *old_conpfeqop; /* pg_constraint.conpfeqop of my former self */
2199
2368
  Oid old_pktable_oid; /* pg_constraint.confrelid of my former
2200
2369
  * self */
@@ -2433,10 +2602,12 @@ typedef struct CreateAmStmt
2433
2602
  typedef struct CreateTrigStmt
2434
2603
  {
2435
2604
  NodeTag type;
2605
+ bool replace; /* replace trigger if already exists */
2606
+ bool isconstraint; /* This is a constraint trigger */
2436
2607
  char *trigname; /* TRIGGER's name */
2437
2608
  RangeVar *relation; /* relation trigger is on */
2438
2609
  List *funcname; /* qual. name of function to call */
2439
- List *args; /* list of (T_String) Values or NIL */
2610
+ List *args; /* list of String or NIL */
2440
2611
  bool row; /* ROW/STATEMENT */
2441
2612
  /* timing uses the TRIGGER_TYPE bits defined in catalog/pg_trigger.h */
2442
2613
  int16 timing; /* BEFORE, AFTER, or INSTEAD */
@@ -2444,7 +2615,6 @@ typedef struct CreateTrigStmt
2444
2615
  int16 events; /* "OR" of INSERT/UPDATE/DELETE/TRUNCATE */
2445
2616
  List *columns; /* column names, or NIL for all columns */
2446
2617
  Node *whenClause; /* qual expression, or NULL if none */
2447
- bool isconstraint; /* This is a constraint trigger */
2448
2618
  /* explicitly named transition data */
2449
2619
  List *transitionRels; /* TriggerTransition nodes, or NIL if none */
2450
2620
  /* The remaining fields are only used for constraint triggers */
@@ -2573,7 +2743,7 @@ typedef struct DefineStmt
2573
2743
  NodeTag type;
2574
2744
  ObjectType kind; /* aggregate, operator, type */
2575
2745
  bool oldstyle; /* hack to signal old CREATE AGG syntax */
2576
- List *defnames; /* qualified name (list of Value strings) */
2746
+ List *defnames; /* qualified name (list of String) */
2577
2747
  List *args; /* a list of TypeName (if needed) */
2578
2748
  List *definition; /* a list of DefElem */
2579
2749
  bool if_not_exists; /* just do nothing if it already exists? */
@@ -2587,7 +2757,7 @@ typedef struct DefineStmt
2587
2757
  typedef struct CreateDomainStmt
2588
2758
  {
2589
2759
  NodeTag type;
2590
- List *domainname; /* qualified name (list of Value strings) */
2760
+ List *domainname; /* qualified name (list of String) */
2591
2761
  TypeName *typeName; /* the base type */
2592
2762
  CollateClause *collClause; /* untransformed COLLATE spec, if any */
2593
2763
  List *constraints; /* constraints (list of Constraint nodes) */
@@ -2600,7 +2770,7 @@ typedef struct CreateDomainStmt
2600
2770
  typedef struct CreateOpClassStmt
2601
2771
  {
2602
2772
  NodeTag type;
2603
- List *opclassname; /* qualified name (list of Value strings) */
2773
+ List *opclassname; /* qualified name (list of String) */
2604
2774
  List *opfamilyname; /* qualified name (ditto); NIL if omitted */
2605
2775
  char *amname; /* name of index AM opclass is for */
2606
2776
  TypeName *datatype; /* datatype of indexed column */
@@ -2632,7 +2802,7 @@ typedef struct CreateOpClassItem
2632
2802
  typedef struct CreateOpFamilyStmt
2633
2803
  {
2634
2804
  NodeTag type;
2635
- List *opfamilyname; /* qualified name (list of Value strings) */
2805
+ List *opfamilyname; /* qualified name (list of String) */
2636
2806
  char *amname; /* name of index AM opfamily is for */
2637
2807
  } CreateOpFamilyStmt;
2638
2808
 
@@ -2643,7 +2813,7 @@ typedef struct CreateOpFamilyStmt
2643
2813
  typedef struct AlterOpFamilyStmt
2644
2814
  {
2645
2815
  NodeTag type;
2646
- List *opfamilyname; /* qualified name (list of Value strings) */
2816
+ List *opfamilyname; /* qualified name (list of String) */
2647
2817
  char *amname; /* name of index AM opfamily is for */
2648
2818
  bool isDrop; /* ADD or DROP the items? */
2649
2819
  List *items; /* List of CreateOpClassItem nodes */
@@ -2713,12 +2883,13 @@ typedef struct SecLabelStmt
2713
2883
  #define CURSOR_OPT_SCROLL 0x0002 /* SCROLL explicitly given */
2714
2884
  #define CURSOR_OPT_NO_SCROLL 0x0004 /* NO SCROLL explicitly given */
2715
2885
  #define CURSOR_OPT_INSENSITIVE 0x0008 /* INSENSITIVE */
2716
- #define CURSOR_OPT_HOLD 0x0010 /* WITH HOLD */
2886
+ #define CURSOR_OPT_ASENSITIVE 0x0010 /* ASENSITIVE */
2887
+ #define CURSOR_OPT_HOLD 0x0020 /* WITH HOLD */
2717
2888
  /* these planner-control flags do not correspond to any SQL grammar: */
2718
- #define CURSOR_OPT_FAST_PLAN 0x0020 /* prefer fast-start plan */
2719
- #define CURSOR_OPT_GENERIC_PLAN 0x0040 /* force use of generic plan */
2720
- #define CURSOR_OPT_CUSTOM_PLAN 0x0080 /* force use of custom plan */
2721
- #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 */
2722
2893
 
2723
2894
  typedef struct DeclareCursorStmt
2724
2895
  {
@@ -2795,6 +2966,7 @@ typedef struct IndexStmt
2795
2966
  SubTransactionId oldFirstRelfilenodeSubid; /* rd_firstRelfilenodeSubid of
2796
2967
  * oldNode */
2797
2968
  bool unique; /* is index unique? */
2969
+ bool nulls_not_distinct; /* null treatment for UNIQUE constraints */
2798
2970
  bool primary; /* is index a primary key? */
2799
2971
  bool isconstraint; /* is it for a pkey/unique constraint? */
2800
2972
  bool deferrable; /* is the constraint DEFERRABLE? */
@@ -2813,14 +2985,30 @@ typedef struct IndexStmt
2813
2985
  typedef struct CreateStatsStmt
2814
2986
  {
2815
2987
  NodeTag type;
2816
- List *defnames; /* qualified name (list of Value strings) */
2817
- 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) */
2818
2990
  List *exprs; /* expressions to build statistics on */
2819
2991
  List *relations; /* rels to build stats on (list of RangeVar) */
2820
2992
  char *stxcomment; /* comment to apply to stats, or NULL */
2993
+ bool transformed; /* true when transformStatsStmt is finished */
2821
2994
  bool if_not_exists; /* do nothing if stats name already exists */
2822
2995
  } CreateStatsStmt;
2823
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
+
2824
3012
  /* ----------------------
2825
3013
  * Alter Statistics Statement
2826
3014
  * ----------------------
@@ -2828,7 +3016,7 @@ typedef struct CreateStatsStmt
2828
3016
  typedef struct AlterStatsStmt
2829
3017
  {
2830
3018
  NodeTag type;
2831
- List *defnames; /* qualified name (list of Value strings) */
3019
+ List *defnames; /* qualified name (list of String) */
2832
3020
  int stxstattarget; /* statistics target */
2833
3021
  bool missing_ok; /* skip error if statistics object is missing */
2834
3022
  } AlterStatsStmt;
@@ -2846,6 +3034,7 @@ typedef struct CreateFunctionStmt
2846
3034
  List *parameters; /* a list of FunctionParameter */
2847
3035
  TypeName *returnType; /* the return type */
2848
3036
  List *options; /* a list of DefElem */
3037
+ Node *sql_body;
2849
3038
  } CreateFunctionStmt;
2850
3039
 
2851
3040
  typedef enum FunctionParameterMode
@@ -2855,7 +3044,9 @@ typedef enum FunctionParameterMode
2855
3044
  FUNC_PARAM_OUT = 'o', /* output only */
2856
3045
  FUNC_PARAM_INOUT = 'b', /* both */
2857
3046
  FUNC_PARAM_VARIADIC = 'v', /* variadic (always input) */
2858
- 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 */
2859
3050
  } FunctionParameterMode;
2860
3051
 
2861
3052
  typedef struct FunctionParameter
@@ -2898,13 +3089,19 @@ typedef struct InlineCodeBlock
2898
3089
 
2899
3090
  /* ----------------------
2900
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.)
2901
3097
  * ----------------------
2902
3098
  */
2903
3099
  typedef struct CallStmt
2904
3100
  {
2905
3101
  NodeTag type;
2906
3102
  FuncCall *funccall; /* from the parser */
2907
- FuncExpr *funcexpr; /* transformed */
3103
+ FuncExpr *funcexpr; /* transformed call, with only input args */
3104
+ List *outargs; /* transformed output-argument expressions */
2908
3105
  } CallStmt;
2909
3106
 
2910
3107
  typedef struct CallContext
@@ -2941,7 +3138,7 @@ typedef struct AlterObjectDependsStmt
2941
3138
  ObjectType objectType; /* OBJECT_FUNCTION, OBJECT_TRIGGER, etc */
2942
3139
  RangeVar *relation; /* in case a table is involved */
2943
3140
  Node *object; /* name of the object */
2944
- Value *extname; /* extension name */
3141
+ String *extname; /* extension name */
2945
3142
  bool remove; /* set true to remove dep rather than add */
2946
3143
  } AlterObjectDependsStmt;
2947
3144
 
@@ -3087,8 +3284,8 @@ typedef struct CompositeTypeStmt
3087
3284
  typedef struct CreateEnumStmt
3088
3285
  {
3089
3286
  NodeTag type;
3090
- List *typeName; /* qualified name (list of Value strings) */
3091
- List *vals; /* enum values (list of Value strings) */
3287
+ List *typeName; /* qualified name (list of String) */
3288
+ List *vals; /* enum values (list of String) */
3092
3289
  } CreateEnumStmt;
3093
3290
 
3094
3291
  /* ----------------------
@@ -3098,7 +3295,7 @@ typedef struct CreateEnumStmt
3098
3295
  typedef struct CreateRangeStmt
3099
3296
  {
3100
3297
  NodeTag type;
3101
- List *typeName; /* qualified name (list of Value strings) */
3298
+ List *typeName; /* qualified name (list of String) */
3102
3299
  List *params; /* range parameters (list of DefElem) */
3103
3300
  } CreateRangeStmt;
3104
3301
 
@@ -3109,7 +3306,7 @@ typedef struct CreateRangeStmt
3109
3306
  typedef struct AlterEnumStmt
3110
3307
  {
3111
3308
  NodeTag type;
3112
- List *typeName; /* qualified name (list of Value strings) */
3309
+ List *typeName; /* qualified name (list of String) */
3113
3310
  char *oldVal; /* old enum value's name, if renaming */
3114
3311
  char *newVal; /* new enum value's name */
3115
3312
  char *newValNeighbor; /* neighboring enum value, if specified */
@@ -3171,6 +3368,12 @@ typedef struct AlterDatabaseStmt
3171
3368
  List *options; /* List of DefElem nodes */
3172
3369
  } AlterDatabaseStmt;
3173
3370
 
3371
+ typedef struct AlterDatabaseRefreshCollStmt
3372
+ {
3373
+ NodeTag type;
3374
+ char *dbname;
3375
+ } AlterDatabaseRefreshCollStmt;
3376
+
3174
3377
  typedef struct AlterDatabaseSetStmt
3175
3378
  {
3176
3379
  NodeTag type;
@@ -3204,18 +3407,12 @@ typedef struct AlterSystemStmt
3204
3407
  * Cluster Statement (support pbrown's cluster index implementation)
3205
3408
  * ----------------------
3206
3409
  */
3207
- typedef enum ClusterOption
3208
- {
3209
- CLUOPT_RECHECK = 1 << 0, /* recheck relation state */
3210
- CLUOPT_VERBOSE = 1 << 1 /* print progress info */
3211
- } ClusterOption;
3212
-
3213
3410
  typedef struct ClusterStmt
3214
3411
  {
3215
3412
  NodeTag type;
3216
3413
  RangeVar *relation; /* relation being indexed, or NULL if all */
3217
3414
  char *indexname; /* original index defined */
3218
- int options; /* OR of ClusterOption flags */
3415
+ List *params; /* list of DefElem nodes */
3219
3416
  } ClusterStmt;
3220
3417
 
3221
3418
  /* ----------------------
@@ -3281,7 +3478,7 @@ typedef struct CreateTableAsStmt
3281
3478
  NodeTag type;
3282
3479
  Node *query; /* the query (see comments above) */
3283
3480
  IntoClause *into; /* destination table */
3284
- ObjectType relkind; /* OBJECT_TABLE or OBJECT_MATVIEW */
3481
+ ObjectType objtype; /* OBJECT_TABLE or OBJECT_MATVIEW */
3285
3482
  bool is_select_into; /* it was written as SELECT INTO */
3286
3483
  bool if_not_exists; /* just do nothing if it already exists? */
3287
3484
  } CreateTableAsStmt;
@@ -3353,11 +3550,6 @@ typedef struct ConstraintsSetStmt
3353
3550
  * REINDEX Statement
3354
3551
  * ----------------------
3355
3552
  */
3356
-
3357
- /* Reindex options */
3358
- #define REINDEXOPT_VERBOSE (1 << 0) /* print progress info */
3359
- #define REINDEXOPT_REPORT_PROGRESS (1 << 1) /* report pgstat progress */
3360
-
3361
3553
  typedef enum ReindexObjectType
3362
3554
  {
3363
3555
  REINDEX_OBJECT_INDEX, /* index */
@@ -3374,8 +3566,7 @@ typedef struct ReindexStmt
3374
3566
  * etc. */
3375
3567
  RangeVar *relation; /* Table or index to reindex */
3376
3568
  const char *name; /* name of database to reindex */
3377
- int options; /* Reindex options flags */
3378
- bool concurrent; /* reindex concurrently? */
3569
+ List *params; /* list of DefElem nodes */
3379
3570
  } ReindexStmt;
3380
3571
 
3381
3572
  /* ----------------------
@@ -3483,7 +3674,7 @@ typedef struct ReassignOwnedStmt
3483
3674
  typedef struct AlterTSDictionaryStmt
3484
3675
  {
3485
3676
  NodeTag type;
3486
- List *dictname; /* qualified name (list of Value strings) */
3677
+ List *dictname; /* qualified name (list of String) */
3487
3678
  List *options; /* List of DefElem nodes */
3488
3679
  } AlterTSDictionaryStmt;
3489
3680
 
@@ -3503,29 +3694,64 @@ typedef struct AlterTSConfigurationStmt
3503
3694
  {
3504
3695
  NodeTag type;
3505
3696
  AlterTSConfigType kind; /* ALTER_TSCONFIG_ADD_MAPPING, etc */
3506
- List *cfgname; /* qualified name (list of Value strings) */
3697
+ List *cfgname; /* qualified name (list of String) */
3507
3698
 
3508
3699
  /*
3509
3700
  * dicts will be non-NIL if ADD/ALTER MAPPING was specified. If dicts is
3510
3701
  * NIL, but tokentype isn't, DROP MAPPING was specified.
3511
3702
  */
3512
- List *tokentype; /* list of Value strings */
3513
- List *dicts; /* list of list of Value strings */
3703
+ List *tokentype; /* list of String */
3704
+ List *dicts; /* list of list of String */
3514
3705
  bool override; /* if true - remove old variant */
3515
3706
  bool replace; /* if true - replace dictionary by another */
3516
3707
  bool missing_ok; /* for DROP - skip error if missing? */
3517
3708
  } AlterTSConfigurationStmt;
3518
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;
3519
3738
 
3520
3739
  typedef struct CreatePublicationStmt
3521
3740
  {
3522
3741
  NodeTag type;
3523
3742
  char *pubname; /* Name of the publication */
3524
3743
  List *options; /* List of DefElem nodes */
3525
- List *tables; /* Optional list of tables to add */
3744
+ List *pubobjects; /* Optional list of publication objects */
3526
3745
  bool for_all_tables; /* Special publication for all tables in db */
3527
3746
  } CreatePublicationStmt;
3528
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
+
3529
3755
  typedef struct AlterPublicationStmt
3530
3756
  {
3531
3757
  NodeTag type;
@@ -3534,10 +3760,14 @@ typedef struct AlterPublicationStmt
3534
3760
  /* parameters used for ALTER PUBLICATION ... WITH */
3535
3761
  List *options; /* List of DefElem nodes */
3536
3762
 
3537
- /* parameters used for ALTER PUBLICATION ... ADD/DROP TABLE */
3538
- 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 */
3539
3768
  bool for_all_tables; /* Special publication for all tables in db */
3540
- DefElemAction tableAction; /* What action to perform with the tables */
3769
+ AlterPublicationAction action; /* What action to perform with the given
3770
+ * objects */
3541
3771
  } AlterPublicationStmt;
3542
3772
 
3543
3773
  typedef struct CreateSubscriptionStmt
@@ -3553,9 +3783,12 @@ typedef enum AlterSubscriptionType
3553
3783
  {
3554
3784
  ALTER_SUBSCRIPTION_OPTIONS,
3555
3785
  ALTER_SUBSCRIPTION_CONNECTION,
3556
- ALTER_SUBSCRIPTION_PUBLICATION,
3786
+ ALTER_SUBSCRIPTION_SET_PUBLICATION,
3787
+ ALTER_SUBSCRIPTION_ADD_PUBLICATION,
3788
+ ALTER_SUBSCRIPTION_DROP_PUBLICATION,
3557
3789
  ALTER_SUBSCRIPTION_REFRESH,
3558
- ALTER_SUBSCRIPTION_ENABLED
3790
+ ALTER_SUBSCRIPTION_ENABLED,
3791
+ ALTER_SUBSCRIPTION_SKIP
3559
3792
  } AlterSubscriptionType;
3560
3793
 
3561
3794
  typedef struct AlterSubscriptionStmt