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
@@ -4,7 +4,7 @@
4
4
  * Definitions for planner's internal data structures, especially Paths.
5
5
  *
6
6
  *
7
- * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
7
+ * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
8
8
  * Portions Copyright (c) 1994, Regents of the University of California
9
9
  *
10
10
  * src/include/nodes/pathnodes.h
@@ -55,10 +55,6 @@ typedef struct QualCost
55
55
  */
56
56
  typedef struct AggClauseCosts
57
57
  {
58
- int numAggs; /* total number of aggregate functions */
59
- int numOrderedAggs; /* number w/ DISTINCT/ORDER BY/WITHIN GROUP */
60
- bool hasNonPartial; /* does any agg not support partial mode? */
61
- bool hasNonSerial; /* is any partial agg non-serializable? */
62
58
  QualCost transCost; /* total per-input-row execution costs */
63
59
  QualCost finalCost; /* total per-aggregated-row costs */
64
60
  Size transitionSpace; /* space for pass-by-ref transition data */
@@ -75,24 +71,13 @@ typedef enum UpperRelationKind
75
71
  * any */
76
72
  UPPERREL_GROUP_AGG, /* result of grouping/aggregation, if any */
77
73
  UPPERREL_WINDOW, /* result of window functions, if any */
74
+ UPPERREL_PARTIAL_DISTINCT, /* result of partial "SELECT DISTINCT", if any */
78
75
  UPPERREL_DISTINCT, /* result of "SELECT DISTINCT", if any */
79
76
  UPPERREL_ORDERED, /* result of ORDER BY, if any */
80
77
  UPPERREL_FINAL /* result of any remaining top-level actions */
81
78
  /* NB: UPPERREL_FINAL must be last enum entry; it's used to size arrays */
82
79
  } UpperRelationKind;
83
80
 
84
- /*
85
- * This enum identifies which type of relation is being planned through the
86
- * inheritance planner. INHKIND_NONE indicates the inheritance planner
87
- * was not used.
88
- */
89
- typedef enum InheritanceKind
90
- {
91
- INHKIND_NONE,
92
- INHKIND_INHERITED,
93
- INHKIND_PARTITIONED
94
- } InheritanceKind;
95
-
96
81
  /*----------
97
82
  * PlannerGlobal
98
83
  * Global information for planning/optimization
@@ -120,8 +105,6 @@ typedef struct PlannerGlobal
120
105
 
121
106
  List *resultRelations; /* "flat" list of integer RT indexes */
122
107
 
123
- List *rootResultRelations; /* "flat" list of integer RT indexes */
124
-
125
108
  List *appendRelations; /* "flat" list of AppendRelInfos */
126
109
 
127
110
  List *relationOids; /* OIDs of relations the plan depends on */
@@ -283,6 +266,17 @@ struct PlannerInfo
283
266
 
284
267
  List *join_info_list; /* list of SpecialJoinInfos */
285
268
 
269
+ /*
270
+ * all_result_relids is empty for SELECT, otherwise it contains at least
271
+ * parse->resultRelation. For UPDATE/DELETE/MERGE across an inheritance
272
+ * or partitioning tree, the result rel's child relids are added. When
273
+ * using multi-level partitioning, intermediate partitioned rels are
274
+ * included. leaf_result_relids is similar except that only actual result
275
+ * tables, not partitioned tables, are included in it.
276
+ */
277
+ Relids all_result_relids; /* set of all result relids */
278
+ Relids leaf_result_relids; /* set of all leaf relids */
279
+
286
280
  /*
287
281
  * Note: for AppendRelInfos describing partitions of a partitioned table,
288
282
  * we guarantee that partitions that come earlier in the partitioned
@@ -290,6 +284,8 @@ struct PlannerInfo
290
284
  */
291
285
  List *append_rel_list; /* list of AppendRelInfos */
292
286
 
287
+ List *row_identity_vars; /* list of RowIdentityVarInfos */
288
+
293
289
  List *rowMarks; /* list of PlanRowMarks */
294
290
 
295
291
  List *placeholder_list; /* list of PlaceHolderInfos */
@@ -316,40 +312,55 @@ struct PlannerInfo
316
312
 
317
313
  /*
318
314
  * The fully-processed targetlist is kept here. It differs from
319
- * parse->targetList in that (for INSERT and UPDATE) it's been reordered
320
- * to match the target table, and defaults have been filled in. Also,
321
- * additional resjunk targets may be present. preprocess_targetlist()
322
- * does most of this work, but note that more resjunk targets can get
323
- * added during appendrel expansion. (Hence, upper_targets mustn't get
324
- * set up till after that.)
315
+ * parse->targetList in that (for INSERT) it's been reordered to match the
316
+ * target table, and defaults have been filled in. Also, additional
317
+ * resjunk targets may be present. preprocess_targetlist() does most of
318
+ * that work, but note that more resjunk targets can get added during
319
+ * appendrel expansion. (Hence, upper_targets mustn't get set up till
320
+ * after that.)
325
321
  */
326
322
  List *processed_tlist;
327
323
 
324
+ /*
325
+ * For UPDATE, this list contains the target table's attribute numbers to
326
+ * which the first N entries of processed_tlist are to be assigned. (Any
327
+ * additional entries in processed_tlist must be resjunk.) DO NOT use the
328
+ * resnos in processed_tlist to identify the UPDATE target columns.
329
+ */
330
+ List *update_colnos;
331
+
328
332
  /* Fields filled during create_plan() for use in setrefs.c */
329
333
  AttrNumber *grouping_map; /* for GroupingFunc fixup */
330
334
  List *minmax_aggs; /* List of MinMaxAggInfos */
331
335
 
332
336
  MemoryContext planner_cxt; /* context holding PlannerInfo */
333
337
 
334
- double total_table_pages; /* # of pages in all non-dummy tables of
338
+ Cardinality total_table_pages; /* # of pages in all non-dummy tables of
335
339
  * query */
336
340
 
337
- double tuple_fraction; /* tuple_fraction passed to query_planner */
338
- double limit_tuples; /* limit_tuples passed to query_planner */
341
+ Selectivity tuple_fraction; /* tuple_fraction passed to query_planner */
342
+ Cardinality limit_tuples; /* limit_tuples passed to query_planner */
339
343
 
340
344
  Index qual_security_level; /* minimum security_level for quals */
341
345
  /* Note: qual_security_level is zero if there are no securityQuals */
342
346
 
343
- InheritanceKind inhTargetKind; /* indicates if the target relation is an
344
- * inheritance child or partition or a
345
- * partitioned table */
346
347
  bool hasJoinRTEs; /* true if any RTEs are RTE_JOIN kind */
347
348
  bool hasLateralRTEs; /* true if any RTEs are marked LATERAL */
348
349
  bool hasHavingQual; /* true if havingQual was non-null */
349
350
  bool hasPseudoConstantQuals; /* true if any RestrictInfo has
350
351
  * pseudoconstant = true */
352
+ bool hasAlternativeSubPlans; /* true if we've made any of those */
351
353
  bool hasRecursion; /* true if planning a recursive WITH item */
352
354
 
355
+ /*
356
+ * Information about aggregates. Filled by preprocess_aggrefs().
357
+ */
358
+ List *agginfos; /* AggInfo structs */
359
+ List *aggtransinfos; /* AggTransInfo structs */
360
+ int numOrderedAggs; /* number w/ DISTINCT/ORDER BY/WITHIN GROUP */
361
+ bool hasNonPartialAggs; /* does any agg not support partial mode? */
362
+ bool hasNonSerialAggs; /* is any partial agg non-serializable? */
363
+
353
364
  /* These fields are used only when hasRecursion is true: */
354
365
  int wt_param_id; /* PARAM_EXEC ID for the work table */
355
366
  struct Path *non_recursive_path; /* a path for non-recursive term */
@@ -358,6 +369,10 @@ struct PlannerInfo
358
369
  Relids curOuterRels; /* outer rels above current node */
359
370
  List *curOuterParams; /* not-yet-assigned NestLoopParams */
360
371
 
372
+ /* These fields are workspace for setrefs.c */
373
+ bool *isAltSubplan; /* array corresponding to glob->subplans */
374
+ bool *isUsedSubplan; /* array corresponding to glob->subplans */
375
+
361
376
  /* optional private data for join_search_hook, e.g., GEQO */
362
377
  void *join_search_private;
363
378
 
@@ -603,9 +618,6 @@ typedef struct PartitionSchemeData *PartitionScheme;
603
618
  * part_rels - RelOptInfos for each partition
604
619
  * all_partrels - Relids set of all partition relids
605
620
  * partexprs, nullable_partexprs - Partition key expressions
606
- * partitioned_child_rels - RT indexes of unpruned partitions of
607
- * this relation that are partitioned tables
608
- * themselves, in hierarchical order
609
621
  *
610
622
  * The partexprs and nullable_partexprs arrays each contain
611
623
  * part_scheme->partnatts elements. Each of the elements is a list of
@@ -621,6 +633,10 @@ typedef struct PartitionSchemeData *PartitionScheme;
621
633
  * to simplify matching join clauses to those lists.
622
634
  *----------
623
635
  */
636
+
637
+ /* Bitmask of flags supported by table AMs */
638
+ #define AMFLAG_HAS_TID_RANGE (1 << 0)
639
+
624
640
  typedef enum RelOptKind
625
641
  {
626
642
  RELOPT_BASEREL,
@@ -666,7 +682,7 @@ typedef struct RelOptInfo
666
682
  Relids relids; /* set of base relids (rangetable indexes) */
667
683
 
668
684
  /* size estimates generated by planner */
669
- double rows; /* estimated number of result tuples */
685
+ Cardinality rows; /* estimated number of result tuples */
670
686
 
671
687
  /* per-relation planner control flags */
672
688
  bool consider_startup; /* keep cheap-startup-cost paths? */
@@ -703,13 +719,15 @@ typedef struct RelOptInfo
703
719
  List *indexlist; /* list of IndexOptInfo */
704
720
  List *statlist; /* list of StatisticExtInfo */
705
721
  BlockNumber pages; /* size estimates derived from pg_class */
706
- double tuples;
722
+ Cardinality tuples;
707
723
  double allvisfrac;
708
724
  Bitmapset *eclass_indexes; /* Indexes in PlannerInfo's eq_classes list of
709
725
  * ECs that mention this rel */
710
726
  PlannerInfo *subroot; /* if subquery */
711
727
  List *subplan_params; /* if subquery */
712
728
  int rel_parallel_workers; /* wanted number of parallel workers */
729
+ uint32 amflags; /* Bitmask of optional features supported by
730
+ * the table AM */
713
731
 
714
732
  /* Information about foreign tables and foreign joins */
715
733
  Oid serverid; /* identifies server for the table or join */
@@ -750,10 +768,12 @@ typedef struct RelOptInfo
750
768
  List *partition_qual; /* Partition constraint, if not the root */
751
769
  struct RelOptInfo **part_rels; /* Array of RelOptInfos of partitions,
752
770
  * stored in the same order as bounds */
771
+ Bitmapset *live_parts; /* Bitmap with members acting as indexes into
772
+ * the part_rels[] array to indicate which
773
+ * partitions survived partition pruning. */
753
774
  Relids all_partrels; /* Relids set of all partition relids */
754
775
  List **partexprs; /* Non-nullable partition key expressions */
755
776
  List **nullable_partexprs; /* Nullable partition key expressions */
756
- List *partitioned_child_rels; /* List of RT indexes */
757
777
  } RelOptInfo;
758
778
 
759
779
  /*
@@ -822,7 +842,7 @@ struct IndexOptInfo
822
842
 
823
843
  /* index-size statistics (from pg_class and elsewhere) */
824
844
  BlockNumber pages; /* number of disk pages in index */
825
- double tuples; /* number of index tuples in index */
845
+ Cardinality tuples; /* number of index tuples in index */
826
846
  int tree_height; /* index tree height, or -1 if unknown */
827
847
 
828
848
  /* index descriptor information */
@@ -892,10 +912,13 @@ typedef struct ForeignKeyOptInfo
892
912
 
893
913
  /* Derived info about whether FK's equality conditions match the query: */
894
914
  int nmatched_ec; /* # of FK cols matched by ECs */
915
+ int nconst_ec; /* # of these ECs that are ec_has_const */
895
916
  int nmatched_rcols; /* # of FK cols matched by non-EC rinfos */
896
917
  int nmatched_ri; /* total # of non-EC rinfos matched to FK */
897
918
  /* Pointer to eclass matching each column's condition, if there is one */
898
919
  struct EquivalenceClass *eclass[INDEX_MAX_KEYS];
920
+ /* Pointer to eclass member for the referencing Var, if there is one */
921
+ struct EquivalenceMember *fk_eclass_member[INDEX_MAX_KEYS];
899
922
  /* List of non-EC RestrictInfos matching each column's condition */
900
923
  List *rinfos[INDEX_MAX_KEYS];
901
924
  } ForeignKeyOptInfo;
@@ -912,9 +935,11 @@ typedef struct StatisticExtInfo
912
935
  NodeTag type;
913
936
 
914
937
  Oid statOid; /* OID of the statistics row */
938
+ bool inherit; /* includes child relations */
915
939
  RelOptInfo *rel; /* back-link to statistic's table */
916
940
  char kind; /* statistics kind of this entry */
917
941
  Bitmapset *keys; /* attnums of the columns covered */
942
+ List *exprs; /* expressions */
918
943
  } StatisticExtInfo;
919
944
 
920
945
  /*
@@ -1046,6 +1071,17 @@ typedef struct PathKey
1046
1071
  bool pk_nulls_first; /* do NULLs come before normal values? */
1047
1072
  } PathKey;
1048
1073
 
1074
+ /*
1075
+ * VolatileFunctionStatus -- allows nodes to cache their
1076
+ * contain_volatile_functions properties. VOLATILITY_UNKNOWN means not yet
1077
+ * determined.
1078
+ */
1079
+ typedef enum VolatileFunctionStatus
1080
+ {
1081
+ VOLATILITY_UNKNOWN = 0,
1082
+ VOLATILITY_VOLATILE,
1083
+ VOLATILITY_NOVOLATILE
1084
+ } VolatileFunctionStatus;
1049
1085
 
1050
1086
  /*
1051
1087
  * PathTarget
@@ -1077,6 +1113,8 @@ typedef struct PathTarget
1077
1113
  Index *sortgrouprefs; /* corresponding sort/group refnos, or 0 */
1078
1114
  QualCost cost; /* cost of evaluating the expressions */
1079
1115
  int width; /* estimated avg width of result tuples */
1116
+ VolatileFunctionStatus has_volatile_expr; /* indicates if exprs contain
1117
+ * any volatile functions. */
1080
1118
  } PathTarget;
1081
1119
 
1082
1120
  /* Convenience macro to get a sort/group refno from a PathTarget */
@@ -1103,7 +1141,7 @@ typedef struct ParamPathInfo
1103
1141
  NodeTag type;
1104
1142
 
1105
1143
  Relids ppi_req_outer; /* rels supplying parameters used by path */
1106
- double ppi_rows; /* estimated number of result tuples */
1144
+ Cardinality ppi_rows; /* estimated number of result tuples */
1107
1145
  List *ppi_clauses; /* join clauses available from outer rels */
1108
1146
  } ParamPathInfo;
1109
1147
 
@@ -1153,7 +1191,7 @@ typedef struct Path
1153
1191
  int parallel_workers; /* desired # of workers; 0 = not parallel */
1154
1192
 
1155
1193
  /* estimated size/costs for path (see costsize.c for more info) */
1156
- double rows; /* estimated number of result tuples */
1194
+ Cardinality rows; /* estimated number of result tuples */
1157
1195
  Cost startup_cost; /* cost expended before fetching any tuples */
1158
1196
  Cost total_cost; /* total cost (assuming all tuples fetched) */
1159
1197
 
@@ -1321,6 +1359,18 @@ typedef struct TidPath
1321
1359
  List *tidquals; /* qual(s) involving CTID = something */
1322
1360
  } TidPath;
1323
1361
 
1362
+ /*
1363
+ * TidRangePath represents a scan by a contiguous range of TIDs
1364
+ *
1365
+ * tidrangequals is an implicitly AND'ed list of qual expressions of the form
1366
+ * "CTID relop pseudoconstant", where relop is one of >,>=,<,<=.
1367
+ */
1368
+ typedef struct TidRangePath
1369
+ {
1370
+ Path path;
1371
+ List *tidrangequals;
1372
+ } TidRangePath;
1373
+
1324
1374
  /*
1325
1375
  * SubqueryScanPath represents a scan of an unflattened subquery-in-FROM
1326
1376
  *
@@ -1401,12 +1451,10 @@ typedef struct CustomPath
1401
1451
  typedef struct AppendPath
1402
1452
  {
1403
1453
  Path path;
1404
- /* RT indexes of non-leaf tables in a partition tree */
1405
- List *partitioned_rels;
1406
1454
  List *subpaths; /* list of component Paths */
1407
1455
  /* Index of first partial path in subpaths; list_length(subpaths) if none */
1408
1456
  int first_partial_path;
1409
- double limit_tuples; /* hard limit on output tuples, or -1 */
1457
+ Cardinality limit_tuples; /* hard limit on output tuples, or -1 */
1410
1458
  } AppendPath;
1411
1459
 
1412
1460
  #define IS_DUMMY_APPEND(p) \
@@ -1427,10 +1475,8 @@ extern bool is_dummy_rel(RelOptInfo *rel);
1427
1475
  typedef struct MergeAppendPath
1428
1476
  {
1429
1477
  Path path;
1430
- /* RT indexes of non-leaf tables in a partition tree */
1431
- List *partitioned_rels;
1432
1478
  List *subpaths; /* list of component Paths */
1433
- double limit_tuples; /* hard limit on output tuples, or -1 */
1479
+ Cardinality limit_tuples; /* hard limit on output tuples, or -1 */
1434
1480
  } MergeAppendPath;
1435
1481
 
1436
1482
  /*
@@ -1458,6 +1504,27 @@ typedef struct MaterialPath
1458
1504
  Path *subpath;
1459
1505
  } MaterialPath;
1460
1506
 
1507
+ /*
1508
+ * MemoizePath represents a Memoize plan node, i.e., a cache that caches
1509
+ * tuples from parameterized paths to save the underlying node from having to
1510
+ * be rescanned for parameter values which are already cached.
1511
+ */
1512
+ typedef struct MemoizePath
1513
+ {
1514
+ Path path;
1515
+ Path *subpath; /* outerpath to cache tuples from */
1516
+ List *hash_operators; /* hash operators for each key */
1517
+ List *param_exprs; /* cache keys */
1518
+ bool singlerow; /* true if the cache entry is to be marked as
1519
+ * complete after caching the first record. */
1520
+ bool binary_mode; /* true when cache key should be compared bit
1521
+ * by bit, false when using hash equality ops */
1522
+ Cardinality calls; /* expected number of rescans */
1523
+ uint32 est_entries; /* The maximum number of entries that the
1524
+ * planner expects will fit in the cache, or 0
1525
+ * if unknown */
1526
+ } MemoizePath;
1527
+
1461
1528
  /*
1462
1529
  * UniquePath represents elimination of distinct rows from the output of
1463
1530
  * its subpath.
@@ -1470,7 +1537,7 @@ typedef struct MaterialPath
1470
1537
  * it's convenient to have a UniquePath in the path tree to signal upper-level
1471
1538
  * routines that the input is known distinct.)
1472
1539
  */
1473
- typedef enum
1540
+ typedef enum UniquePathMethod
1474
1541
  {
1475
1542
  UNIQUE_PATH_NOOP, /* input is known unique already */
1476
1543
  UNIQUE_PATH_HASH, /* use hashing */
@@ -1540,7 +1607,10 @@ typedef struct JoinPath
1540
1607
  * A nested-loop path needs no special fields.
1541
1608
  */
1542
1609
 
1543
- typedef JoinPath NestPath;
1610
+ typedef struct NestPath
1611
+ {
1612
+ JoinPath jpath;
1613
+ } NestPath;
1544
1614
 
1545
1615
  /*
1546
1616
  * A mergejoin path has these fields.
@@ -1601,7 +1671,7 @@ typedef struct HashPath
1601
1671
  JoinPath jpath;
1602
1672
  List *path_hashclauses; /* join clauses used for hashing */
1603
1673
  int num_batches; /* number of batches expected */
1604
- double inner_rows_total; /* total inner rows expected */
1674
+ Cardinality inner_rows_total; /* total inner rows expected */
1605
1675
  } HashPath;
1606
1676
 
1607
1677
  /*
@@ -1704,7 +1774,7 @@ typedef struct AggPath
1704
1774
  Path *subpath; /* path representing input source */
1705
1775
  AggStrategy aggstrategy; /* basic strategy, see nodes.h */
1706
1776
  AggSplit aggsplit; /* agg-splitting mode, see nodes.h */
1707
- double numGroups; /* estimated number of groups in input */
1777
+ Cardinality numGroups; /* estimated number of groups in input */
1708
1778
  uint64 transitionSpace; /* for pass-by-ref transition data */
1709
1779
  List *groupClause; /* a list of SortGroupClause's */
1710
1780
  List *qual; /* quals (HAVING quals), if any */
@@ -1718,7 +1788,7 @@ typedef struct GroupingSetData
1718
1788
  {
1719
1789
  NodeTag type;
1720
1790
  List *set; /* grouping set as list of sortgrouprefs */
1721
- double numGroups; /* est. number of result groups */
1791
+ Cardinality numGroups; /* est. number of result groups */
1722
1792
  } GroupingSetData;
1723
1793
 
1724
1794
  typedef struct RollupData
@@ -1727,7 +1797,7 @@ typedef struct RollupData
1727
1797
  List *groupClause; /* applicable subset of parse->groupClause */
1728
1798
  List *gsets; /* lists of integer indexes into groupClause */
1729
1799
  List *gsets_data; /* list of GroupingSetData */
1730
- double numGroups; /* est. number of result groups */
1800
+ Cardinality numGroups; /* est. number of result groups */
1731
1801
  bool hashable; /* can be hashed */
1732
1802
  bool is_hashed; /* to be implemented as a hashagg */
1733
1803
  } RollupData;
@@ -1764,6 +1834,9 @@ typedef struct WindowAggPath
1764
1834
  Path path;
1765
1835
  Path *subpath; /* path representing input source */
1766
1836
  WindowClause *winclause; /* WindowClause we'll be using */
1837
+ List *qual; /* lower-level WindowAgg runconditions */
1838
+ bool topwindow; /* false for all apart from the WindowAgg
1839
+ * that's closest to the root of the plan */
1767
1840
  } WindowAggPath;
1768
1841
 
1769
1842
  /*
@@ -1778,7 +1851,7 @@ typedef struct SetOpPath
1778
1851
  List *distinctList; /* SortGroupClauses identifying target cols */
1779
1852
  AttrNumber flagColIdx; /* where is the flag column, if any */
1780
1853
  int firstFlag; /* flag value for first input relation */
1781
- double numGroups; /* estimated number of groups in input */
1854
+ Cardinality numGroups; /* estimated number of groups in input */
1782
1855
  } SetOpPath;
1783
1856
 
1784
1857
  /*
@@ -1791,7 +1864,7 @@ typedef struct RecursiveUnionPath
1791
1864
  Path *rightpath;
1792
1865
  List *distinctList; /* SortGroupClauses identifying target cols */
1793
1866
  int wtParam; /* ID of Param representing work table */
1794
- double numGroups; /* estimated number of groups in input */
1867
+ Cardinality numGroups; /* estimated number of groups in input */
1795
1868
  } RecursiveUnionPath;
1796
1869
 
1797
1870
  /*
@@ -1806,28 +1879,30 @@ typedef struct LockRowsPath
1806
1879
  } LockRowsPath;
1807
1880
 
1808
1881
  /*
1809
- * ModifyTablePath represents performing INSERT/UPDATE/DELETE modifications
1882
+ * ModifyTablePath represents performing INSERT/UPDATE/DELETE/MERGE
1810
1883
  *
1811
1884
  * We represent most things that will be in the ModifyTable plan node
1812
- * literally, except we have child Path(s) not Plan(s). But analysis of the
1885
+ * literally, except we have a child Path not Plan. But analysis of the
1813
1886
  * OnConflictExpr is deferred to createplan.c, as is collection of FDW data.
1814
1887
  */
1815
1888
  typedef struct ModifyTablePath
1816
1889
  {
1817
1890
  Path path;
1818
- CmdType operation; /* INSERT, UPDATE, or DELETE */
1891
+ Path *subpath; /* Path producing source data */
1892
+ CmdType operation; /* INSERT, UPDATE, DELETE, or MERGE */
1819
1893
  bool canSetTag; /* do we set the command tag/es_processed? */
1820
1894
  Index nominalRelation; /* Parent RT index for use of EXPLAIN */
1821
1895
  Index rootRelation; /* Root RT index, if target is partitioned */
1822
- bool partColsUpdated; /* some part key in hierarchy updated */
1896
+ bool partColsUpdated; /* some part key in hierarchy updated? */
1823
1897
  List *resultRelations; /* integer list of RT indexes */
1824
- List *subpaths; /* Path(s) producing source data */
1825
- List *subroots; /* per-target-table PlannerInfos */
1898
+ List *updateColnosLists; /* per-target-table update_colnos lists */
1826
1899
  List *withCheckOptionLists; /* per-target-table WCO lists */
1827
1900
  List *returningLists; /* per-target-table RETURNING tlists */
1828
1901
  List *rowMarks; /* PlanRowMarks (non-locking only) */
1829
1902
  OnConflictExpr *onconflict; /* ON CONFLICT clause, or NULL */
1830
1903
  int epqParam; /* ID of Param for EvalPlanQual re-eval */
1904
+ List *mergeActionLists; /* per-target-table lists of actions for
1905
+ * MERGE */
1831
1906
  } ModifyTablePath;
1832
1907
 
1833
1908
  /*
@@ -1999,6 +2074,9 @@ typedef struct RestrictInfo
1999
2074
 
2000
2075
  bool leakproof; /* true if known to contain no leaked Vars */
2001
2076
 
2077
+ VolatileFunctionStatus has_volatile; /* to indicate if clause contains
2078
+ * any volatile functions. */
2079
+
2002
2080
  Index security_level; /* see comment above */
2003
2081
 
2004
2082
  /* The set of relids (varnos) actually referenced in the clause: */
@@ -2052,6 +2130,10 @@ typedef struct RestrictInfo
2052
2130
  Selectivity right_bucketsize; /* avg bucketsize of right side */
2053
2131
  Selectivity left_mcvfreq; /* left side's most common val's freq */
2054
2132
  Selectivity right_mcvfreq; /* right side's most common val's freq */
2133
+
2134
+ /* hash equality operators used for memoize nodes, else InvalidOid */
2135
+ Oid left_hasheqoperator;
2136
+ Oid right_hasheqoperator;
2055
2137
  } RestrictInfo;
2056
2138
 
2057
2139
  /*
@@ -2278,6 +2360,34 @@ typedef struct AppendRelInfo
2278
2360
  Oid parent_reloid; /* OID of parent relation */
2279
2361
  } AppendRelInfo;
2280
2362
 
2363
+ /*
2364
+ * Information about a row-identity "resjunk" column in UPDATE/DELETE/MERGE.
2365
+ *
2366
+ * In partitioned UPDATE/DELETE/MERGE it's important for child partitions to
2367
+ * share row-identity columns whenever possible, so as not to chew up too many
2368
+ * targetlist columns. We use these structs to track which identity columns
2369
+ * have been requested. In the finished plan, each of these will give rise
2370
+ * to one resjunk entry in the targetlist of the ModifyTable's subplan node.
2371
+ *
2372
+ * All the Vars stored in RowIdentityVarInfos must have varno ROWID_VAR, for
2373
+ * convenience of detecting duplicate requests. We'll replace that, in the
2374
+ * final plan, with the varno of the generating rel.
2375
+ *
2376
+ * Outside this list, a Var with varno ROWID_VAR and varattno k is a reference
2377
+ * to the k-th element of the row_identity_vars list (k counting from 1).
2378
+ * We add such a reference to root->processed_tlist when creating the entry,
2379
+ * and it propagates into the plan tree from there.
2380
+ */
2381
+ typedef struct RowIdentityVarInfo
2382
+ {
2383
+ NodeTag type;
2384
+
2385
+ Var *rowidvar; /* Var to be evaluated (but varno=ROWID_VAR) */
2386
+ int32 rowidwidth; /* estimated average width */
2387
+ char *rowidname; /* name of the resjunk column */
2388
+ Relids rowidrels; /* RTE indexes of target rels using this */
2389
+ } RowIdentityVarInfo;
2390
+
2281
2391
  /*
2282
2392
  * For each distinct placeholder expression generated during planning, we
2283
2393
  * store a PlaceHolderInfo node in the PlannerInfo node's placeholder_list.
@@ -2512,7 +2622,7 @@ typedef struct
2512
2622
  typedef struct
2513
2623
  {
2514
2624
  bool limit_needed;
2515
- double limit_tuples;
2625
+ Cardinality limit_tuples;
2516
2626
  int64 count_est;
2517
2627
  int64 offset_est;
2518
2628
  } FinalPathExtraData;
@@ -2543,15 +2653,82 @@ typedef struct JoinCostWorkspace
2543
2653
  Cost inner_rescan_run_cost;
2544
2654
 
2545
2655
  /* private for cost_mergejoin code */
2546
- double outer_rows;
2547
- double inner_rows;
2548
- double outer_skip_rows;
2549
- double inner_skip_rows;
2656
+ Cardinality outer_rows;
2657
+ Cardinality inner_rows;
2658
+ Cardinality outer_skip_rows;
2659
+ Cardinality inner_skip_rows;
2550
2660
 
2551
2661
  /* private for cost_hashjoin code */
2552
2662
  int numbuckets;
2553
2663
  int numbatches;
2554
- double inner_rows_total;
2664
+ Cardinality inner_rows_total;
2555
2665
  } JoinCostWorkspace;
2556
2666
 
2667
+ /*
2668
+ * AggInfo holds information about an aggregate that needs to be computed.
2669
+ * Multiple Aggrefs in a query can refer to the same AggInfo by having the
2670
+ * same 'aggno' value, so that the aggregate is computed only once.
2671
+ */
2672
+ typedef struct AggInfo
2673
+ {
2674
+ /*
2675
+ * Link to an Aggref expr this state value is for.
2676
+ *
2677
+ * There can be multiple identical Aggref's sharing the same per-agg. This
2678
+ * points to the first one of them.
2679
+ */
2680
+ Aggref *representative_aggref;
2681
+
2682
+ int transno;
2683
+
2684
+ /*
2685
+ * "shareable" is false if this agg cannot share state values with other
2686
+ * aggregates because the final function is read-write.
2687
+ */
2688
+ bool shareable;
2689
+
2690
+ /* Oid of the final function or InvalidOid */
2691
+ Oid finalfn_oid;
2692
+
2693
+ } AggInfo;
2694
+
2695
+ /*
2696
+ * AggTransInfo holds information about transition state that is used by one
2697
+ * or more aggregates in the query. Multiple aggregates can share the same
2698
+ * transition state, if they have the same inputs and the same transition
2699
+ * function. Aggrefs that share the same transition info have the same
2700
+ * 'aggtransno' value.
2701
+ */
2702
+ typedef struct AggTransInfo
2703
+ {
2704
+ List *args;
2705
+ Expr *aggfilter;
2706
+
2707
+ /* Oid of the state transition function */
2708
+ Oid transfn_oid;
2709
+
2710
+ /* Oid of the serialization function or InvalidOid */
2711
+ Oid serialfn_oid;
2712
+
2713
+ /* Oid of the deserialization function or InvalidOid */
2714
+ Oid deserialfn_oid;
2715
+
2716
+ /* Oid of the combine function or InvalidOid */
2717
+ Oid combinefn_oid;
2718
+
2719
+ /* Oid of state value's datatype */
2720
+ Oid aggtranstype;
2721
+ int32 aggtranstypmod;
2722
+ int transtypeLen;
2723
+ bool transtypeByVal;
2724
+ int32 aggtransspace;
2725
+
2726
+ /*
2727
+ * initial value from pg_aggregate entry
2728
+ */
2729
+ Datum initValue;
2730
+ bool initValueIsNull;
2731
+
2732
+ } AggTransInfo;
2733
+
2557
2734
  #endif /* PATHNODES_H */